{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "hired-photographer",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "regular-consultancy",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "naval-bicycle",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -6.9,  -0.1,  -1.1, ...,  -2.1,  -0.6,   0.9],\n",
       "       [ -4.7,  -0.7,   1.7, ...,  -3.1,  -1.2,  -2.4],\n",
       "       [  3.4,  -0.7,  -2.3, ...,  10.4,   0.8,   6.2],\n",
       "       ...,\n",
       "       [  3.5,  -6.5,   5.1, ...,  -7.8,   0.7,   3.7],\n",
       "       [  0.4,   0.9,  -6.4, ...,  -1.8, -10.2,  -1.7],\n",
       "       [ -5.6,   4. ,   0.9, ...,   3.6,  -1.8,   6.5]])"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建一个符合正太分布的500个股票504天的涨跌幅数据\n",
    "stock_day_rise = np.random.normal(0, 4, (500, 504))\n",
    "stock_day_rise = np.round(stock_day_rise, 1)\n",
    "stock_day_rise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "written-backing",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>494</th>\n",
       "      <th>495</th>\n",
       "      <th>496</th>\n",
       "      <th>497</th>\n",
       "      <th>498</th>\n",
       "      <th>499</th>\n",
       "      <th>500</th>\n",
       "      <th>501</th>\n",
       "      <th>502</th>\n",
       "      <th>503</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-6.9</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-4.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-13.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>...</td>\n",
       "      <td>7.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-5.1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3.4</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>1.1</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.8</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.1</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>10.4</td>\n",
       "      <td>0.8</td>\n",
       "      <td>6.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1.9</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.7</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>7.5</td>\n",
       "      <td>2.5</td>\n",
       "      <td>...</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-1.3</td>\n",
       "      <td>4.4</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>2.3</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>...</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-7.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>4.4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>7.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>4.7</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2.7</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>3.5</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>3.5</td>\n",
       "      <td>...</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>...</td>\n",
       "      <td>6.4</td>\n",
       "      <td>-11.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>-5.6</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>7.7</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>4.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     0    1    2    3    4    5    6     7    8    9    ...  494   495  496  \\\n",
       "0   -6.9 -0.1 -1.1 -3.1 -0.7  0.0  5.8   2.1  1.6 -2.9  ... -4.5   5.1 -0.5   \n",
       "1   -4.7 -0.7  1.7 -0.3  2.8 -3.4  4.7 -13.9  2.3 -2.1  ...  7.8   0.1 -5.1   \n",
       "2    3.4 -0.7 -2.3  1.7  1.3  2.0 -6.2  -6.2 -3.4  1.1  ... -3.8  -2.4  0.0   \n",
       "3    1.9 -3.4 -3.1 -3.4  4.1 -3.3 -3.7  -1.2  7.5  2.5  ...  6.1   0.5 -4.4   \n",
       "4   -1.3  4.4  2.7 -4.2 -4.1 -0.5  2.3   5.0 -3.3  3.4  ...  3.3   1.1  4.8   \n",
       "..   ...  ...  ...  ...  ...  ...  ...   ...  ...  ...  ...  ...   ...  ...   \n",
       "495  0.5 -4.5  0.6 -3.6  1.6 -2.6 -4.5   0.2 -0.2  2.8  ...  2.1   4.4  3.0   \n",
       "496  7.5 -1.6  2.0  2.6 -0.6  1.5 -4.9   4.7  6.3  1.3  ... -0.8  -1.7  1.3   \n",
       "497  3.5 -6.5  5.1 -2.5 -3.6 -3.6 -4.7  -4.0  2.6  3.5  ...  5.6  -4.7  3.6   \n",
       "498  0.4  0.9 -6.4  6.0  1.4  0.5  6.2  -1.8 -2.6  2.4  ...  6.4 -11.4  3.1   \n",
       "499 -5.6  4.0  0.9 -2.4 -2.9  7.7 -1.4   4.1  2.3  4.6  ... -4.9   6.3  1.1   \n",
       "\n",
       "     497  498  499  500   501   502  503  \n",
       "0   -5.0  1.6  8.0 -8.5  -2.1  -0.6  0.9  \n",
       "1    4.0 -7.5  2.4  4.4  -3.1  -1.2 -2.4  \n",
       "2    4.3  6.1 -0.2 -0.3  10.4   0.8  6.2  \n",
       "3   -4.2 -7.4  5.8  1.2  -7.5   0.5 -3.6  \n",
       "4   -7.1 -1.6 -8.6 -6.4   1.5  -3.3 -2.5  \n",
       "..   ...  ...  ...  ...   ...   ...  ...  \n",
       "495 -2.4  4.3  1.8  5.1  -3.5  -2.2  3.0  \n",
       "496 -1.0 -3.3  3.6  2.7   0.1  -9.3  3.5  \n",
       "497  0.4  5.4 -5.6 -0.2  -7.8   0.7  3.7  \n",
       "498  1.2 -8.5 -0.4  0.5  -1.8 -10.2 -1.7  \n",
       "499  4.8 -1.9  0.9 -1.1   3.6  -1.8  6.5  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用Pandas中的数据结构\n",
    "stock_day_rise_df = pd.DataFrame(stock_day_rise)\n",
    "stock_day_rise_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "spread-crossing",
   "metadata": {},
   "outputs": [],
   "source": [
    "#构造行索引索引序列\n",
    "stock_code = ['股票' + str(i) for i in range(stock_day_rise.shape[0])]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "swiss-wichita",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>494</th>\n",
       "      <th>495</th>\n",
       "      <th>496</th>\n",
       "      <th>497</th>\n",
       "      <th>498</th>\n",
       "      <th>499</th>\n",
       "      <th>500</th>\n",
       "      <th>501</th>\n",
       "      <th>502</th>\n",
       "      <th>503</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-6.9</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>-4.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-13.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>...</td>\n",
       "      <td>7.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-5.1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>3.4</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>1.1</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.8</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.1</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>10.4</td>\n",
       "      <td>0.8</td>\n",
       "      <td>6.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>1.9</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.7</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>7.5</td>\n",
       "      <td>2.5</td>\n",
       "      <td>...</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>-1.3</td>\n",
       "      <td>4.4</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>2.3</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>...</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-7.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>4.4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>7.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>4.7</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2.7</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>3.5</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>3.5</td>\n",
       "      <td>...</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>...</td>\n",
       "      <td>6.4</td>\n",
       "      <td>-11.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-5.6</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>7.7</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>4.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       0    1    2    3    4    5    6     7    8    9    ...  494   495  496  \\\n",
       "股票0   -6.9 -0.1 -1.1 -3.1 -0.7  0.0  5.8   2.1  1.6 -2.9  ... -4.5   5.1 -0.5   \n",
       "股票1   -4.7 -0.7  1.7 -0.3  2.8 -3.4  4.7 -13.9  2.3 -2.1  ...  7.8   0.1 -5.1   \n",
       "股票2    3.4 -0.7 -2.3  1.7  1.3  2.0 -6.2  -6.2 -3.4  1.1  ... -3.8  -2.4  0.0   \n",
       "股票3    1.9 -3.4 -3.1 -3.4  4.1 -3.3 -3.7  -1.2  7.5  2.5  ...  6.1   0.5 -4.4   \n",
       "股票4   -1.3  4.4  2.7 -4.2 -4.1 -0.5  2.3   5.0 -3.3  3.4  ...  3.3   1.1  4.8   \n",
       "...    ...  ...  ...  ...  ...  ...  ...   ...  ...  ...  ...  ...   ...  ...   \n",
       "股票495  0.5 -4.5  0.6 -3.6  1.6 -2.6 -4.5   0.2 -0.2  2.8  ...  2.1   4.4  3.0   \n",
       "股票496  7.5 -1.6  2.0  2.6 -0.6  1.5 -4.9   4.7  6.3  1.3  ... -0.8  -1.7  1.3   \n",
       "股票497  3.5 -6.5  5.1 -2.5 -3.6 -3.6 -4.7  -4.0  2.6  3.5  ...  5.6  -4.7  3.6   \n",
       "股票498  0.4  0.9 -6.4  6.0  1.4  0.5  6.2  -1.8 -2.6  2.4  ...  6.4 -11.4  3.1   \n",
       "股票499 -5.6  4.0  0.9 -2.4 -2.9  7.7 -1.4   4.1  2.3  4.6  ... -4.9   6.3  1.1   \n",
       "\n",
       "       497  498  499  500   501   502  503  \n",
       "股票0   -5.0  1.6  8.0 -8.5  -2.1  -0.6  0.9  \n",
       "股票1    4.0 -7.5  2.4  4.4  -3.1  -1.2 -2.4  \n",
       "股票2    4.3  6.1 -0.2 -0.3  10.4   0.8  6.2  \n",
       "股票3   -4.2 -7.4  5.8  1.2  -7.5   0.5 -3.6  \n",
       "股票4   -7.1 -1.6 -8.6 -6.4   1.5  -3.3 -2.5  \n",
       "...    ...  ...  ...  ...   ...   ...  ...  \n",
       "股票495 -2.4  4.3  1.8  5.1  -3.5  -2.2  3.0  \n",
       "股票496 -1.0 -3.3  3.6  2.7   0.1  -9.3  3.5  \n",
       "股票497  0.4  5.4 -5.6 -0.2  -7.8   0.7  3.7  \n",
       "股票498  1.2 -8.5 -0.4  0.5  -1.8 -10.2 -1.7  \n",
       "股票499  4.8 -1.9  0.9 -1.1   3.6  -1.8  6.5  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 添加行索引\n",
    "data = pd.DataFrame(stock_day_rise, index=stock_code)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "departmental-pennsylvania",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2017-01-02', '2017-01-03', '2017-01-04', '2017-01-05',\n",
       "               '2017-01-06', '2017-01-09', '2017-01-10', '2017-01-11',\n",
       "               '2017-01-12', '2017-01-13',\n",
       "               ...\n",
       "               '2018-11-23', '2018-11-26', '2018-11-27', '2018-11-28',\n",
       "               '2018-11-29', '2018-11-30', '2018-12-03', '2018-12-04',\n",
       "               '2018-12-05', '2018-12-06'],\n",
       "              dtype='datetime64[ns]', length=504, freq='B')"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 生成一个时间的序列，略过周末非交易日\n",
    "date = pd.date_range('2017-01-01', periods=stock_day_rise.shape[1], freq='B')\n",
    "date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "detected-wireless",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-6.9</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>-4.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-13.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>...</td>\n",
       "      <td>7.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-5.1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>3.4</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>1.1</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.8</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.1</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>10.4</td>\n",
       "      <td>0.8</td>\n",
       "      <td>6.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>1.9</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.7</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>7.5</td>\n",
       "      <td>2.5</td>\n",
       "      <td>...</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>-1.3</td>\n",
       "      <td>4.4</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>2.3</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>...</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-7.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>4.4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>7.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>4.7</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2.7</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>3.5</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>3.5</td>\n",
       "      <td>...</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>...</td>\n",
       "      <td>6.4</td>\n",
       "      <td>-11.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-5.6</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>7.7</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>4.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "股票0          -6.9        -0.1        -1.1        -3.1        -0.7         0.0   \n",
       "股票1          -4.7        -0.7         1.7        -0.3         2.8        -3.4   \n",
       "股票2           3.4        -0.7        -2.3         1.7         1.3         2.0   \n",
       "股票3           1.9        -3.4        -3.1        -3.4         4.1        -3.3   \n",
       "股票4          -1.3         4.4         2.7        -4.2        -4.1        -0.5   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495         0.5        -4.5         0.6        -3.6         1.6        -2.6   \n",
       "股票496         7.5        -1.6         2.0         2.6        -0.6         1.5   \n",
       "股票497         3.5        -6.5         5.1        -2.5        -3.6        -3.6   \n",
       "股票498         0.4         0.9        -6.4         6.0         1.4         0.5   \n",
       "股票499        -5.6         4.0         0.9        -2.4        -2.9         7.7   \n",
       "\n",
       "       2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "股票0           5.8         2.1         1.6        -2.9  ...        -4.5   \n",
       "股票1           4.7       -13.9         2.3        -2.1  ...         7.8   \n",
       "股票2          -6.2        -6.2        -3.4         1.1  ...        -3.8   \n",
       "股票3          -3.7        -1.2         7.5         2.5  ...         6.1   \n",
       "股票4           2.3         5.0        -3.3         3.4  ...         3.3   \n",
       "...           ...         ...         ...         ...  ...         ...   \n",
       "股票495        -4.5         0.2        -0.2         2.8  ...         2.1   \n",
       "股票496        -4.9         4.7         6.3         1.3  ...        -0.8   \n",
       "股票497        -4.7        -4.0         2.6         3.5  ...         5.6   \n",
       "股票498         6.2        -1.8        -2.6         2.4  ...         6.4   \n",
       "股票499        -1.4         4.1         2.3         4.6  ...        -4.9   \n",
       "\n",
       "       2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "股票0           5.1        -0.5        -5.0         1.6         8.0        -8.5   \n",
       "股票1           0.1        -5.1         4.0        -7.5         2.4         4.4   \n",
       "股票2          -2.4         0.0         4.3         6.1        -0.2        -0.3   \n",
       "股票3           0.5        -4.4        -4.2        -7.4         5.8         1.2   \n",
       "股票4           1.1         4.8        -7.1        -1.6        -8.6        -6.4   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495         4.4         3.0        -2.4         4.3         1.8         5.1   \n",
       "股票496        -1.7         1.3        -1.0        -3.3         3.6         2.7   \n",
       "股票497        -4.7         3.6         0.4         5.4        -5.6        -0.2   \n",
       "股票498       -11.4         3.1         1.2        -8.5        -0.4         0.5   \n",
       "股票499         6.3         1.1         4.8        -1.9         0.9        -1.1   \n",
       "\n",
       "       2018-12-04  2018-12-05  2018-12-06  \n",
       "股票0          -2.1        -0.6         0.9  \n",
       "股票1          -3.1        -1.2        -2.4  \n",
       "股票2          10.4         0.8         6.2  \n",
       "股票3          -7.5         0.5        -3.6  \n",
       "股票4           1.5        -3.3        -2.5  \n",
       "...           ...         ...         ...  \n",
       "股票495        -3.5        -2.2         3.0  \n",
       "股票496         0.1        -9.3         3.5  \n",
       "股票497        -7.8         0.7         3.7  \n",
       "股票498        -1.8       -10.2        -1.7  \n",
       "股票499         3.6        -1.8         6.5  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# index代表行索引，columns代表列索引\n",
    "data = pd.DataFrame(stock_day_rise, index=stock_code, columns=date)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "consecutive-bosnia",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -6.9,  -0.1,  -1.1, ...,  -2.1,  -0.6,   0.9],\n",
       "       [ -4.7,  -0.7,   1.7, ...,  -3.1,  -1.2,  -2.4],\n",
       "       [  3.4,  -0.7,  -2.3, ...,  10.4,   0.8,   6.2],\n",
       "       ...,\n",
       "       [  3.5,  -6.5,   5.1, ...,  -7.8,   0.7,   3.7],\n",
       "       [  0.4,   0.9,  -6.4, ...,  -1.8, -10.2,  -1.7],\n",
       "       [ -5.6,   4. ,   0.9, ...,   3.6,  -1.8,   6.5]])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "empirical-welcome",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(500, 504)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "going-coral",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2017-01-02    float64\n",
       "2017-01-03    float64\n",
       "2017-01-04    float64\n",
       "2017-01-05    float64\n",
       "2017-01-06    float64\n",
       "               ...   \n",
       "2018-11-30    float64\n",
       "2018-12-03    float64\n",
       "2018-12-04    float64\n",
       "2018-12-05    float64\n",
       "2018-12-06    float64\n",
       "Freq: B, Length: 504, dtype: object"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dtypes    # pandas里面每一列的数据结构可能不一样，numpy是整个数组的数据类型都一致"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "frozen-telling",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "reserved-henry",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['股票0', '股票1', '股票2', '股票3', '股票4', '股票5', '股票6', '股票7', '股票8', '股票9',\n",
       "       ...\n",
       "       '股票490', '股票491', '股票492', '股票493', '股票494', '股票495', '股票496', '股票497',\n",
       "       '股票498', '股票499'],\n",
       "      dtype='object', length=500)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "assured-gibraltar",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2017-01-02', '2017-01-03', '2017-01-04', '2017-01-05',\n",
       "               '2017-01-06', '2017-01-09', '2017-01-10', '2017-01-11',\n",
       "               '2017-01-12', '2017-01-13',\n",
       "               ...\n",
       "               '2018-11-23', '2018-11-26', '2018-11-27', '2018-11-28',\n",
       "               '2018-11-29', '2018-11-30', '2018-12-03', '2018-12-04',\n",
       "               '2018-12-05', '2018-12-06'],\n",
       "              dtype='datetime64[ns]', length=504, freq='B')"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "laughing-thompson",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>股票0</th>\n",
       "      <th>股票1</th>\n",
       "      <th>股票2</th>\n",
       "      <th>股票3</th>\n",
       "      <th>股票4</th>\n",
       "      <th>股票5</th>\n",
       "      <th>股票6</th>\n",
       "      <th>股票7</th>\n",
       "      <th>股票8</th>\n",
       "      <th>股票9</th>\n",
       "      <th>...</th>\n",
       "      <th>股票490</th>\n",
       "      <th>股票491</th>\n",
       "      <th>股票492</th>\n",
       "      <th>股票493</th>\n",
       "      <th>股票494</th>\n",
       "      <th>股票495</th>\n",
       "      <th>股票496</th>\n",
       "      <th>股票497</th>\n",
       "      <th>股票498</th>\n",
       "      <th>股票499</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-01-02</th>\n",
       "      <td>-6.9</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.4</td>\n",
       "      <td>1.9</td>\n",
       "      <td>-1.3</td>\n",
       "      <td>7.6</td>\n",
       "      <td>-3.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>...</td>\n",
       "      <td>2.9</td>\n",
       "      <td>5.3</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>7.5</td>\n",
       "      <td>3.5</td>\n",
       "      <td>0.4</td>\n",
       "      <td>-5.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-03</th>\n",
       "      <td>-0.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>7.1</td>\n",
       "      <td>6.1</td>\n",
       "      <td>6.3</td>\n",
       "      <td>0.9</td>\n",
       "      <td>5.5</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>8.9</td>\n",
       "      <td>1.4</td>\n",
       "      <td>5.1</td>\n",
       "      <td>6.3</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>0.9</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04</th>\n",
       "      <td>-1.1</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-5.8</td>\n",
       "      <td>2.2</td>\n",
       "      <td>-9.0</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>...</td>\n",
       "      <td>4.6</td>\n",
       "      <td>6.0</td>\n",
       "      <td>2.2</td>\n",
       "      <td>8.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>0.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-05</th>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>3.7</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>4.7</td>\n",
       "      <td>7.0</td>\n",
       "      <td>-1.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>6.0</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-06</th>\n",
       "      <td>-0.7</td>\n",
       "      <td>2.8</td>\n",
       "      <td>1.3</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>4.7</td>\n",
       "      <td>5.2</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>4.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>-2.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-30</th>\n",
       "      <td>8.0</td>\n",
       "      <td>2.4</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>5.8</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>...</td>\n",
       "      <td>2.4</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>1.8</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-03</th>\n",
       "      <td>-8.5</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>7.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>0.3</td>\n",
       "      <td>2.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>5.3</td>\n",
       "      <td>-1.5</td>\n",
       "      <td>5.0</td>\n",
       "      <td>5.1</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-04</th>\n",
       "      <td>-2.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>10.4</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>1.5</td>\n",
       "      <td>1.5</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>5.6</td>\n",
       "      <td>1.2</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-9.1</td>\n",
       "      <td>1.3</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-05</th>\n",
       "      <td>-0.6</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>0.8</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-0.9</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.6</td>\n",
       "      <td>3.8</td>\n",
       "      <td>5.8</td>\n",
       "      <td>3.4</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>0.7</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-06</th>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>6.7</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-8.0</td>\n",
       "      <td>1.7</td>\n",
       "      <td>...</td>\n",
       "      <td>2.2</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>10.2</td>\n",
       "      <td>3.0</td>\n",
       "      <td>3.5</td>\n",
       "      <td>3.7</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>504 rows × 500 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            股票0  股票1   股票2  股票3  股票4  股票5  股票6  股票7  股票8  股票9  ...  股票490  \\\n",
       "2017-01-02 -6.9 -4.7   3.4  1.9 -1.3  7.6 -3.0  1.0  1.4 -2.5  ...    2.9   \n",
       "2017-01-03 -0.1 -0.7  -0.7 -3.4  4.4  7.1  6.1  6.3  0.9  5.5  ...   -2.6   \n",
       "2017-01-04 -1.1  1.7  -2.3 -3.1  2.7 -5.8  2.2 -9.0 -3.1 -0.1  ...    4.6   \n",
       "2017-01-05 -3.1 -0.3   1.7 -3.4 -4.2  0.1 -1.6  2.4  3.7 -1.6  ...   -2.7   \n",
       "2017-01-06 -0.7  2.8   1.3  4.1 -4.1 -2.3 -6.2 -1.6  4.7  5.2  ...   -3.1   \n",
       "...         ...  ...   ...  ...  ...  ...  ...  ...  ...  ...  ...    ...   \n",
       "2018-11-30  8.0  2.4  -0.2  5.8 -8.6 -3.4  1.5  4.8 -0.5 -1.4  ...    2.4   \n",
       "2018-12-03 -8.5  4.4  -0.3  1.2 -6.4  7.3  2.0 -2.2  0.3  2.3  ...   -1.6   \n",
       "2018-12-04 -2.1 -3.1  10.4 -7.5  1.5  1.5  5.6 -1.9  5.6  1.2  ...   -0.1   \n",
       "2018-12-05 -0.6 -1.2   0.8  0.5 -3.3 -0.9  1.3 -1.9 -0.7  1.3  ...   -7.5   \n",
       "2018-12-06  0.9 -2.4   6.2 -3.6 -2.5  6.7 -1.6  0.9 -8.0  1.7  ...    2.2   \n",
       "\n",
       "            股票491  股票492  股票493  股票494  股票495  股票496  股票497  股票498  股票499  \n",
       "2017-01-02    5.3    4.7   -2.1    0.4    0.5    7.5    3.5    0.4   -5.6  \n",
       "2017-01-03    8.9    1.4    5.1    6.3   -4.5   -1.6   -6.5    0.9    4.0  \n",
       "2017-01-04    6.0    2.2    8.2   -7.4    0.6    2.0    5.1   -6.4    0.9  \n",
       "2017-01-05   -0.3    4.7    7.0   -1.5   -3.6    2.6   -2.5    6.0   -2.4  \n",
       "2017-01-06    4.5   -1.6   -2.1    1.0    1.6   -0.6   -3.6    1.4   -2.9  \n",
       "...           ...    ...    ...    ...    ...    ...    ...    ...    ...  \n",
       "2018-11-30   -1.6   -0.7   -0.6    2.4    1.8    3.6   -5.6   -0.4    0.9  \n",
       "2018-12-03   -1.4    5.3   -1.5    5.0    5.1    2.7   -0.2    0.5   -1.1  \n",
       "2018-12-04    1.5   -9.1    1.3    4.0   -3.5    0.1   -7.8   -1.8    3.6  \n",
       "2018-12-05    2.6    3.8    5.8    3.4   -2.2   -9.3    0.7  -10.2   -1.8  \n",
       "2018-12-06   -1.7    4.8   -3.4   10.2    3.0    3.5    3.7   -1.7    6.5  \n",
       "\n",
       "[504 rows x 500 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.T   # 转置， 行变成列，列变成行"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "threaded-composite",
   "metadata": {},
   "source": [
    "有数据返回的就不会修改原数据，没有返回的会修改原数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "illegal-roulette",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-6.9</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>-4.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-13.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>...</td>\n",
       "      <td>7.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-5.1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>3.4</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>1.1</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.8</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.1</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>10.4</td>\n",
       "      <td>0.8</td>\n",
       "      <td>6.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>1.9</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.7</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>7.5</td>\n",
       "      <td>2.5</td>\n",
       "      <td>...</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>-1.3</td>\n",
       "      <td>4.4</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>2.3</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>...</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-7.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "股票0        -6.9        -0.1        -1.1        -3.1        -0.7         0.0   \n",
       "股票1        -4.7        -0.7         1.7        -0.3         2.8        -3.4   \n",
       "股票2         3.4        -0.7        -2.3         1.7         1.3         2.0   \n",
       "股票3         1.9        -3.4        -3.1        -3.4         4.1        -3.3   \n",
       "股票4        -1.3         4.4         2.7        -4.2        -4.1        -0.5   \n",
       "\n",
       "     2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "股票0         5.8         2.1         1.6        -2.9  ...        -4.5   \n",
       "股票1         4.7       -13.9         2.3        -2.1  ...         7.8   \n",
       "股票2        -6.2        -6.2        -3.4         1.1  ...        -3.8   \n",
       "股票3        -3.7        -1.2         7.5         2.5  ...         6.1   \n",
       "股票4         2.3         5.0        -3.3         3.4  ...         3.3   \n",
       "\n",
       "     2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "股票0         5.1        -0.5        -5.0         1.6         8.0        -8.5   \n",
       "股票1         0.1        -5.1         4.0        -7.5         2.4         4.4   \n",
       "股票2        -2.4         0.0         4.3         6.1        -0.2        -0.3   \n",
       "股票3         0.5        -4.4        -4.2        -7.4         5.8         1.2   \n",
       "股票4         1.1         4.8        -7.1        -1.6        -8.6        -6.4   \n",
       "\n",
       "     2018-12-04  2018-12-05  2018-12-06  \n",
       "股票0        -2.1        -0.6         0.9  \n",
       "股票1        -3.1        -1.2        -2.4  \n",
       "股票2        10.4         0.8         6.2  \n",
       "股票3        -7.5         0.5        -3.6  \n",
       "股票4         1.5        -3.3        -2.5  \n",
       "\n",
       "[5 rows x 504 columns]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "excess-edmonton",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>4.4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>7.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>4.7</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2.7</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>3.5</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>3.5</td>\n",
       "      <td>...</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>...</td>\n",
       "      <td>6.4</td>\n",
       "      <td>-11.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-5.6</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>7.7</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>4.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "股票495         0.5        -4.5         0.6        -3.6         1.6        -2.6   \n",
       "股票496         7.5        -1.6         2.0         2.6        -0.6         1.5   \n",
       "股票497         3.5        -6.5         5.1        -2.5        -3.6        -3.6   \n",
       "股票498         0.4         0.9        -6.4         6.0         1.4         0.5   \n",
       "股票499        -5.6         4.0         0.9        -2.4        -2.9         7.7   \n",
       "\n",
       "       2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "股票495        -4.5         0.2        -0.2         2.8  ...         2.1   \n",
       "股票496        -4.9         4.7         6.3         1.3  ...        -0.8   \n",
       "股票497        -4.7        -4.0         2.6         3.5  ...         5.6   \n",
       "股票498         6.2        -1.8        -2.6         2.4  ...         6.4   \n",
       "股票499        -1.4         4.1         2.3         4.6  ...        -4.9   \n",
       "\n",
       "       2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "股票495         4.4         3.0        -2.4         4.3         1.8         5.1   \n",
       "股票496        -1.7         1.3        -1.0        -3.3         3.6         2.7   \n",
       "股票497        -4.7         3.6         0.4         5.4        -5.6        -0.2   \n",
       "股票498       -11.4         3.1         1.2        -8.5        -0.4         0.5   \n",
       "股票499         6.3         1.1         4.8        -1.9         0.9        -1.1   \n",
       "\n",
       "       2018-12-04  2018-12-05  2018-12-06  \n",
       "股票495        -3.5        -2.2         3.0  \n",
       "股票496         0.1        -9.3         3.5  \n",
       "股票497        -7.8         0.7         3.7  \n",
       "股票498        -1.8       -10.2        -1.7  \n",
       "股票499         3.6        -1.8         6.5  \n",
       "\n",
       "[5 rows x 504 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "answering-sleeping",
   "metadata": {},
   "source": [
    "### DatatFrame索引的设置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "integrated-mountain",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "Index does not support mutable operations",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-32-30810a7eae62>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m# 修改行列索引值\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m499\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"688981\"\u001b[0m \u001b[1;31m# 无法修改\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36m__setitem__\u001b[1;34m(self, key, value)\u001b[0m\n\u001b[0;32m   4275\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0mfinal\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4276\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__setitem__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 4277\u001b[1;33m         \u001b[1;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Index does not support mutable operations\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   4278\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4279\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__getitem__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: Index does not support mutable operations"
     ]
    }
   ],
   "source": [
    "# 修改行列索引值\n",
    "data.index[499] = \"688981\" # 无法修改\n",
    "# 数据的索引，不支持直接修改里面的内容，但可以将整个索引换掉"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "mechanical-brook",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 通过整体修改，不能单个赋值\n",
    "data.index = [i for i in range(100,600)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "continuing-negotiation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-6.9</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>-4.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-13.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>...</td>\n",
       "      <td>7.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-5.1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>3.4</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>1.1</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.8</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.1</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>10.4</td>\n",
       "      <td>0.8</td>\n",
       "      <td>6.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>1.9</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.7</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>7.5</td>\n",
       "      <td>2.5</td>\n",
       "      <td>...</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>-1.3</td>\n",
       "      <td>4.4</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>2.3</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>...</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-7.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>4.4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>7.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>4.7</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2.7</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>3.5</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>3.5</td>\n",
       "      <td>...</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>...</td>\n",
       "      <td>6.4</td>\n",
       "      <td>-11.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-5.6</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>7.7</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>4.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "股票0          -6.9        -0.1        -1.1        -3.1        -0.7         0.0   \n",
       "股票1          -4.7        -0.7         1.7        -0.3         2.8        -3.4   \n",
       "股票2           3.4        -0.7        -2.3         1.7         1.3         2.0   \n",
       "股票3           1.9        -3.4        -3.1        -3.4         4.1        -3.3   \n",
       "股票4          -1.3         4.4         2.7        -4.2        -4.1        -0.5   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495         0.5        -4.5         0.6        -3.6         1.6        -2.6   \n",
       "股票496         7.5        -1.6         2.0         2.6        -0.6         1.5   \n",
       "股票497         3.5        -6.5         5.1        -2.5        -3.6        -3.6   \n",
       "股票498         0.4         0.9        -6.4         6.0         1.4         0.5   \n",
       "股票499        -5.6         4.0         0.9        -2.4        -2.9         7.7   \n",
       "\n",
       "       2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "股票0           5.8         2.1         1.6        -2.9  ...        -4.5   \n",
       "股票1           4.7       -13.9         2.3        -2.1  ...         7.8   \n",
       "股票2          -6.2        -6.2        -3.4         1.1  ...        -3.8   \n",
       "股票3          -3.7        -1.2         7.5         2.5  ...         6.1   \n",
       "股票4           2.3         5.0        -3.3         3.4  ...         3.3   \n",
       "...           ...         ...         ...         ...  ...         ...   \n",
       "股票495        -4.5         0.2        -0.2         2.8  ...         2.1   \n",
       "股票496        -4.9         4.7         6.3         1.3  ...        -0.8   \n",
       "股票497        -4.7        -4.0         2.6         3.5  ...         5.6   \n",
       "股票498         6.2        -1.8        -2.6         2.4  ...         6.4   \n",
       "股票499        -1.4         4.1         2.3         4.6  ...        -4.9   \n",
       "\n",
       "       2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "股票0           5.1        -0.5        -5.0         1.6         8.0        -8.5   \n",
       "股票1           0.1        -5.1         4.0        -7.5         2.4         4.4   \n",
       "股票2          -2.4         0.0         4.3         6.1        -0.2        -0.3   \n",
       "股票3           0.5        -4.4        -4.2        -7.4         5.8         1.2   \n",
       "股票4           1.1         4.8        -7.1        -1.6        -8.6        -6.4   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495         4.4         3.0        -2.4         4.3         1.8         5.1   \n",
       "股票496        -1.7         1.3        -1.0        -3.3         3.6         2.7   \n",
       "股票497        -4.7         3.6         0.4         5.4        -5.6        -0.2   \n",
       "股票498       -11.4         3.1         1.2        -8.5        -0.4         0.5   \n",
       "股票499         6.3         1.1         4.8        -1.9         0.9        -1.1   \n",
       "\n",
       "       2018-12-04  2018-12-05  2018-12-06  \n",
       "股票0          -2.1        -0.6         0.9  \n",
       "股票1          -3.1        -1.2        -2.4  \n",
       "股票2          10.4         0.8         6.2  \n",
       "股票3          -7.5         0.5        -3.6  \n",
       "股票4           1.5        -3.3        -2.5  \n",
       "...           ...         ...         ...  \n",
       "股票495        -3.5        -2.2         3.0  \n",
       "股票496         0.1        -9.3         3.5  \n",
       "股票497        -7.8         0.7         3.7  \n",
       "股票498        -1.8       -10.2        -1.7  \n",
       "股票499         3.6        -1.8         6.5  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.index = stock_code\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "built-blast",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>2017-01-02 00:00:00</th>\n",
       "      <th>2017-01-03 00:00:00</th>\n",
       "      <th>2017-01-04 00:00:00</th>\n",
       "      <th>2017-01-05 00:00:00</th>\n",
       "      <th>2017-01-06 00:00:00</th>\n",
       "      <th>2017-01-09 00:00:00</th>\n",
       "      <th>2017-01-10 00:00:00</th>\n",
       "      <th>2017-01-11 00:00:00</th>\n",
       "      <th>2017-01-12 00:00:00</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23 00:00:00</th>\n",
       "      <th>2018-11-26 00:00:00</th>\n",
       "      <th>2018-11-27 00:00:00</th>\n",
       "      <th>2018-11-28 00:00:00</th>\n",
       "      <th>2018-11-29 00:00:00</th>\n",
       "      <th>2018-11-30 00:00:00</th>\n",
       "      <th>2018-12-03 00:00:00</th>\n",
       "      <th>2018-12-04 00:00:00</th>\n",
       "      <th>2018-12-05 00:00:00</th>\n",
       "      <th>2018-12-06 00:00:00</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>股票0</td>\n",
       "      <td>-6.9</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>股票1</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-13.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>...</td>\n",
       "      <td>7.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-5.1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>股票2</td>\n",
       "      <td>3.4</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.8</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.1</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>10.4</td>\n",
       "      <td>0.8</td>\n",
       "      <td>6.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>股票3</td>\n",
       "      <td>1.9</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.7</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>7.5</td>\n",
       "      <td>...</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>股票4</td>\n",
       "      <td>-1.3</td>\n",
       "      <td>4.4</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>2.3</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>...</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-7.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>股票495</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>4.4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>股票496</td>\n",
       "      <td>7.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>4.7</td>\n",
       "      <td>6.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2.7</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>股票497</td>\n",
       "      <td>3.5</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>...</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>股票498</td>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>...</td>\n",
       "      <td>6.4</td>\n",
       "      <td>-11.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>股票499</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>7.7</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 505 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     index  2017-01-02 00:00:00  2017-01-03 00:00:00  2017-01-04 00:00:00  \\\n",
       "0      股票0                 -6.9                 -0.1                 -1.1   \n",
       "1      股票1                 -4.7                 -0.7                  1.7   \n",
       "2      股票2                  3.4                 -0.7                 -2.3   \n",
       "3      股票3                  1.9                 -3.4                 -3.1   \n",
       "4      股票4                 -1.3                  4.4                  2.7   \n",
       "..     ...                  ...                  ...                  ...   \n",
       "495  股票495                  0.5                 -4.5                  0.6   \n",
       "496  股票496                  7.5                 -1.6                  2.0   \n",
       "497  股票497                  3.5                 -6.5                  5.1   \n",
       "498  股票498                  0.4                  0.9                 -6.4   \n",
       "499  股票499                 -5.6                  4.0                  0.9   \n",
       "\n",
       "     2017-01-05 00:00:00  2017-01-06 00:00:00  2017-01-09 00:00:00  \\\n",
       "0                   -3.1                 -0.7                  0.0   \n",
       "1                   -0.3                  2.8                 -3.4   \n",
       "2                    1.7                  1.3                  2.0   \n",
       "3                   -3.4                  4.1                 -3.3   \n",
       "4                   -4.2                 -4.1                 -0.5   \n",
       "..                   ...                  ...                  ...   \n",
       "495                 -3.6                  1.6                 -2.6   \n",
       "496                  2.6                 -0.6                  1.5   \n",
       "497                 -2.5                 -3.6                 -3.6   \n",
       "498                  6.0                  1.4                  0.5   \n",
       "499                 -2.4                 -2.9                  7.7   \n",
       "\n",
       "     2017-01-10 00:00:00  2017-01-11 00:00:00  2017-01-12 00:00:00  ...  \\\n",
       "0                    5.8                  2.1                  1.6  ...   \n",
       "1                    4.7                -13.9                  2.3  ...   \n",
       "2                   -6.2                 -6.2                 -3.4  ...   \n",
       "3                   -3.7                 -1.2                  7.5  ...   \n",
       "4                    2.3                  5.0                 -3.3  ...   \n",
       "..                   ...                  ...                  ...  ...   \n",
       "495                 -4.5                  0.2                 -0.2  ...   \n",
       "496                 -4.9                  4.7                  6.3  ...   \n",
       "497                 -4.7                 -4.0                  2.6  ...   \n",
       "498                  6.2                 -1.8                 -2.6  ...   \n",
       "499                 -1.4                  4.1                  2.3  ...   \n",
       "\n",
       "     2018-11-23 00:00:00  2018-11-26 00:00:00  2018-11-27 00:00:00  \\\n",
       "0                   -4.5                  5.1                 -0.5   \n",
       "1                    7.8                  0.1                 -5.1   \n",
       "2                   -3.8                 -2.4                  0.0   \n",
       "3                    6.1                  0.5                 -4.4   \n",
       "4                    3.3                  1.1                  4.8   \n",
       "..                   ...                  ...                  ...   \n",
       "495                  2.1                  4.4                  3.0   \n",
       "496                 -0.8                 -1.7                  1.3   \n",
       "497                  5.6                 -4.7                  3.6   \n",
       "498                  6.4                -11.4                  3.1   \n",
       "499                 -4.9                  6.3                  1.1   \n",
       "\n",
       "     2018-11-28 00:00:00  2018-11-29 00:00:00  2018-11-30 00:00:00  \\\n",
       "0                   -5.0                  1.6                  8.0   \n",
       "1                    4.0                 -7.5                  2.4   \n",
       "2                    4.3                  6.1                 -0.2   \n",
       "3                   -4.2                 -7.4                  5.8   \n",
       "4                   -7.1                 -1.6                 -8.6   \n",
       "..                   ...                  ...                  ...   \n",
       "495                 -2.4                  4.3                  1.8   \n",
       "496                 -1.0                 -3.3                  3.6   \n",
       "497                  0.4                  5.4                 -5.6   \n",
       "498                  1.2                 -8.5                 -0.4   \n",
       "499                  4.8                 -1.9                  0.9   \n",
       "\n",
       "     2018-12-03 00:00:00  2018-12-04 00:00:00  2018-12-05 00:00:00  \\\n",
       "0                   -8.5                 -2.1                 -0.6   \n",
       "1                    4.4                 -3.1                 -1.2   \n",
       "2                   -0.3                 10.4                  0.8   \n",
       "3                    1.2                 -7.5                  0.5   \n",
       "4                   -6.4                  1.5                 -3.3   \n",
       "..                   ...                  ...                  ...   \n",
       "495                  5.1                 -3.5                 -2.2   \n",
       "496                  2.7                  0.1                 -9.3   \n",
       "497                 -0.2                 -7.8                  0.7   \n",
       "498                  0.5                 -1.8                -10.2   \n",
       "499                 -1.1                  3.6                 -1.8   \n",
       "\n",
       "     2018-12-06 00:00:00  \n",
       "0                    0.9  \n",
       "1                   -2.4  \n",
       "2                    6.2  \n",
       "3                   -3.6  \n",
       "4                   -2.5  \n",
       "..                   ...  \n",
       "495                  3.0  \n",
       "496                  3.5  \n",
       "497                  3.7  \n",
       "498                 -1.7  \n",
       "499                  6.5  \n",
       "\n",
       "[500 rows x 505 columns]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 重置索引\n",
    "data_new_index = data.reset_index(drop=False)   # drop为False代表不将索引列丢弃，而是将他变成一列数据， 如果为True则会丢弃这一列\n",
    "data_new_index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "radio-inspection",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>index</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-6.9</td>\n",
       "      <td>-0.1</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>0.0</td>\n",
       "      <td>5.8</td>\n",
       "      <td>2.1</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>-5.0</td>\n",
       "      <td>1.6</td>\n",
       "      <td>8.0</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>0.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>-4.7</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>1.7</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>2.8</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.7</td>\n",
       "      <td>-13.9</td>\n",
       "      <td>2.3</td>\n",
       "      <td>-2.1</td>\n",
       "      <td>...</td>\n",
       "      <td>7.8</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-5.1</td>\n",
       "      <td>4.0</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>2.4</td>\n",
       "      <td>4.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>-2.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>3.4</td>\n",
       "      <td>-0.7</td>\n",
       "      <td>-2.3</td>\n",
       "      <td>1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>2.0</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-6.2</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>1.1</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.8</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>0.0</td>\n",
       "      <td>4.3</td>\n",
       "      <td>6.1</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-0.3</td>\n",
       "      <td>10.4</td>\n",
       "      <td>0.8</td>\n",
       "      <td>6.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>1.9</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>-3.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-3.7</td>\n",
       "      <td>-1.2</td>\n",
       "      <td>7.5</td>\n",
       "      <td>2.5</td>\n",
       "      <td>...</td>\n",
       "      <td>6.1</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.4</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-7.4</td>\n",
       "      <td>5.8</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-3.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>-1.3</td>\n",
       "      <td>4.4</td>\n",
       "      <td>2.7</td>\n",
       "      <td>-4.2</td>\n",
       "      <td>-4.1</td>\n",
       "      <td>-0.5</td>\n",
       "      <td>2.3</td>\n",
       "      <td>5.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.4</td>\n",
       "      <td>...</td>\n",
       "      <td>3.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-7.1</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>-2.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>0.5</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>1.6</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>-4.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>2.8</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>4.4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>4.3</td>\n",
       "      <td>1.8</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>-2.2</td>\n",
       "      <td>3.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>7.5</td>\n",
       "      <td>-1.6</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>-0.6</td>\n",
       "      <td>1.5</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>4.7</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.3</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.8</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>1.3</td>\n",
       "      <td>-1.0</td>\n",
       "      <td>-3.3</td>\n",
       "      <td>3.6</td>\n",
       "      <td>2.7</td>\n",
       "      <td>0.1</td>\n",
       "      <td>-9.3</td>\n",
       "      <td>3.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>3.5</td>\n",
       "      <td>-6.5</td>\n",
       "      <td>5.1</td>\n",
       "      <td>-2.5</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-3.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>3.5</td>\n",
       "      <td>...</td>\n",
       "      <td>5.6</td>\n",
       "      <td>-4.7</td>\n",
       "      <td>3.6</td>\n",
       "      <td>0.4</td>\n",
       "      <td>5.4</td>\n",
       "      <td>-5.6</td>\n",
       "      <td>-0.2</td>\n",
       "      <td>-7.8</td>\n",
       "      <td>0.7</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>0.4</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-6.4</td>\n",
       "      <td>6.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-2.6</td>\n",
       "      <td>2.4</td>\n",
       "      <td>...</td>\n",
       "      <td>6.4</td>\n",
       "      <td>-11.4</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.2</td>\n",
       "      <td>-8.5</td>\n",
       "      <td>-0.4</td>\n",
       "      <td>0.5</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>-10.2</td>\n",
       "      <td>-1.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-5.6</td>\n",
       "      <td>4.0</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-2.4</td>\n",
       "      <td>-2.9</td>\n",
       "      <td>7.7</td>\n",
       "      <td>-1.4</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.3</td>\n",
       "      <td>4.6</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.9</td>\n",
       "      <td>6.3</td>\n",
       "      <td>1.1</td>\n",
       "      <td>4.8</td>\n",
       "      <td>-1.9</td>\n",
       "      <td>0.9</td>\n",
       "      <td>-1.1</td>\n",
       "      <td>3.6</td>\n",
       "      <td>-1.8</td>\n",
       "      <td>6.5</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "index                                                                           \n",
       "股票0          -6.9        -0.1        -1.1        -3.1        -0.7         0.0   \n",
       "股票1          -4.7        -0.7         1.7        -0.3         2.8        -3.4   \n",
       "股票2           3.4        -0.7        -2.3         1.7         1.3         2.0   \n",
       "股票3           1.9        -3.4        -3.1        -3.4         4.1        -3.3   \n",
       "股票4          -1.3         4.4         2.7        -4.2        -4.1        -0.5   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495         0.5        -4.5         0.6        -3.6         1.6        -2.6   \n",
       "股票496         7.5        -1.6         2.0         2.6        -0.6         1.5   \n",
       "股票497         3.5        -6.5         5.1        -2.5        -3.6        -3.6   \n",
       "股票498         0.4         0.9        -6.4         6.0         1.4         0.5   \n",
       "股票499        -5.6         4.0         0.9        -2.4        -2.9         7.7   \n",
       "\n",
       "       2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "index                                                  ...               \n",
       "股票0           5.8         2.1         1.6        -2.9  ...        -4.5   \n",
       "股票1           4.7       -13.9         2.3        -2.1  ...         7.8   \n",
       "股票2          -6.2        -6.2        -3.4         1.1  ...        -3.8   \n",
       "股票3          -3.7        -1.2         7.5         2.5  ...         6.1   \n",
       "股票4           2.3         5.0        -3.3         3.4  ...         3.3   \n",
       "...           ...         ...         ...         ...  ...         ...   \n",
       "股票495        -4.5         0.2        -0.2         2.8  ...         2.1   \n",
       "股票496        -4.9         4.7         6.3         1.3  ...        -0.8   \n",
       "股票497        -4.7        -4.0         2.6         3.5  ...         5.6   \n",
       "股票498         6.2        -1.8        -2.6         2.4  ...         6.4   \n",
       "股票499        -1.4         4.1         2.3         4.6  ...        -4.9   \n",
       "\n",
       "       2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "index                                                                           \n",
       "股票0           5.1        -0.5        -5.0         1.6         8.0        -8.5   \n",
       "股票1           0.1        -5.1         4.0        -7.5         2.4         4.4   \n",
       "股票2          -2.4         0.0         4.3         6.1        -0.2        -0.3   \n",
       "股票3           0.5        -4.4        -4.2        -7.4         5.8         1.2   \n",
       "股票4           1.1         4.8        -7.1        -1.6        -8.6        -6.4   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495         4.4         3.0        -2.4         4.3         1.8         5.1   \n",
       "股票496        -1.7         1.3        -1.0        -3.3         3.6         2.7   \n",
       "股票497        -4.7         3.6         0.4         5.4        -5.6        -0.2   \n",
       "股票498       -11.4         3.1         1.2        -8.5        -0.4         0.5   \n",
       "股票499         6.3         1.1         4.8        -1.9         0.9        -1.1   \n",
       "\n",
       "       2018-12-04  2018-12-05  2018-12-06  \n",
       "index                                      \n",
       "股票0          -2.1        -0.6         0.9  \n",
       "股票1          -3.1        -1.2        -2.4  \n",
       "股票2          10.4         0.8         6.2  \n",
       "股票3          -7.5         0.5        -3.6  \n",
       "股票4           1.5        -3.3        -2.5  \n",
       "...           ...         ...         ...  \n",
       "股票495        -3.5        -2.2         3.0  \n",
       "股票496         0.1        -9.3         3.5  \n",
       "股票497        -7.8         0.7         3.7  \n",
       "股票498        -1.8       -10.2        -1.7  \n",
       "股票499         3.6        -1.8         6.5  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_new_index.set_index(['index'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "greek-parker",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "deadly-ferry",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>month</th>\n",
       "      <th>year</th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   month  year  sale\n",
       "0      1     1    55\n",
       "1      4     1    40\n",
       "2      7     2    84\n",
       "3     10     2    31"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({'month':[1,4,7,10], 'year':[1, 1, 2, 2], 'sale':[55, 40, 84, 31]})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "aware-plymouth",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       year  sale\n",
       "month            \n",
       "1         1    55\n",
       "4         1    40\n",
       "7         2    84\n",
       "10        2    31"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.set_index(['month'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "insured-credits",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>1</th>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>7</th>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            sale\n",
       "year month      \n",
       "1    1        55\n",
       "     4        40\n",
       "2    7        84\n",
       "     10       31"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.set_index(['year','month'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "documented-paraguay",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th>year</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <th>1</th>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <th>1</th>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <th>2</th>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <th>2</th>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            sale\n",
       "month year      \n",
       "1     1       55\n",
       "4     1       40\n",
       "7     2       84\n",
       "10    2       31"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.set_index(['month','year'])   # 索引具有唯一性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "fuzzy-stroke",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "股票0     -6.9\n",
       "股票1     -4.7\n",
       "股票2      3.4\n",
       "股票3      1.9\n",
       "股票4     -1.3\n",
       "        ... \n",
       "股票495    0.5\n",
       "股票496    7.5\n",
       "股票497    3.5\n",
       "股票498    0.4\n",
       "股票499   -5.6\n",
       "Name: 2017-01-02 00:00:00, Length: 500, dtype: float64"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['2017-01-02']   # Dataframe里面的 每一列是一个series\n",
    "#  pandas取数据是    先 列 后 行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "convinced-genius",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-6.9"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['2017-01-02']['股票0']    # 先 列 后 行   numpy和python原生都是先行后列"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "moving-lucas",
   "metadata": {},
   "source": [
    "### Series"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "played-senior",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    10\n",
       "1    11\n",
       "2    12\n",
       "3    13\n",
       "4    14\n",
       "5    15\n",
       "6    16\n",
       "7    17\n",
       "8    18\n",
       "9    19\n",
       "dtype: int32"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series(np.arange(10, 20))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "progressive-penalty",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "价格0     6.7\n",
       "价格1     5.6\n",
       "价格2     3.0\n",
       "价格3    10.0\n",
       "价格4     2.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series([6.7,5.6,3,10,2], index=[\"价格\"+str(i) for i in range(5)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "incoming-hazard",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 通过字典数据创建\n",
    "se = pd.Series({'red':100, 'blue':200, 'green': 500, 'yellow':1000})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "conceptual-bacon",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "red        100\n",
       "blue       200\n",
       "green      500\n",
       "yellow    1000\n",
       "dtype: int64"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "se"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "played-firmware",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['red', 'blue', 'green', 'yellow'], dtype='object')"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "se.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "desperate-muscle",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 100,  200,  500, 1000], dtype=int64)"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "se.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "environmental-census",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "naked-output",
   "metadata": {},
   "source": [
    "### 基本操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "later-simple",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'F:\\\\龙坡\\\\代码\\\\ai2021\\\\移动2033'"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "german-spotlight",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('data/stock_day.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "verified-filling",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>14.28</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>13.16</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>12.90</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>12.70</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>12.52</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88  24.16  23.53   95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78  23.53  22.80   60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37  22.82  22.71   52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76  22.28  22.02   36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99  21.92  21.48   23331.04          0.44      2.05   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-03-06  13.17  14.48  14.28  13.13  179831.72          1.12      8.51   \n",
       "2015-03-05  12.88  13.45  13.16  12.87   93180.39          0.26      2.02   \n",
       "2015-03-04  12.80  12.92  12.90  12.61   67075.44          0.20      1.57   \n",
       "2015-03-03  12.52  13.06  12.70  12.52  139071.61          0.18      1.44   \n",
       "2015-03-02  12.25  12.67  12.52  12.20   96291.73          0.32      2.62   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "olympic-bidding",
   "metadata": {},
   "source": [
    "* 直接使用行列索引(先列后行)\n",
    "* 结合loc或者iloc使用索引\n",
    "* 使用ix组合索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "saved-signature",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    23.53\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 通过行列索引\n",
    "data['open'][['2018-02-27']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "brazilian-female",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "\"None of [Index(['2018-02-27'], dtype='object')] are in the [columns]\"",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-75-bbd8d252bc27>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdata\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'2018-02-27'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'open'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   3028\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mis_iterator\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3029\u001b[0m                 \u001b[0mkey\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3030\u001b[1;33m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mloc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_listlike_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mraise_missing\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3031\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3032\u001b[0m         \u001b[1;31m# take() does not accept boolean indexers\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_get_listlike_indexer\u001b[1;34m(self, key, axis, raise_missing)\u001b[0m\n\u001b[0;32m   1264\u001b[0m             \u001b[0mkeyarr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnew_indexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0max\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_reindex_non_unique\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkeyarr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1265\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1266\u001b[1;33m         \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_validate_read_indexer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkeyarr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maxis\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mraise_missing\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mraise_missing\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1267\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mkeyarr\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindexer\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1268\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\indexing.py\u001b[0m in \u001b[0;36m_validate_read_indexer\u001b[1;34m(self, key, indexer, axis, raise_missing)\u001b[0m\n\u001b[0;32m   1306\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mmissing\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1307\u001b[0m                 \u001b[0maxis_name\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_axis_name\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1308\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mf\"None of [{key}] are in the [{axis_name}]\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   1309\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   1310\u001b[0m             \u001b[0max\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mobj\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_get_axis\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0maxis\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: \"None of [Index(['2018-02-27'], dtype='object')] are in the [columns]\""
     ]
    }
   ],
   "source": [
    "data[['2018-02-27']]['open']   # 用原始的【】写法 必须是先列后行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "independent-administrator",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "23.53"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['open']['2018-02-27']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "romance-german",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    23.53\n",
       "2018-02-26    22.80\n",
       "2018-02-23    22.88\n",
       "2018-02-22    22.25\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用loc\n",
    "# loc:只能指定行列索引的名字\n",
    "data.loc['2018-02-27':'2018-02-22', 'open']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "stone-munich",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high\n",
       "2018-02-27  23.53  25.88\n",
       "2018-02-26  22.80  23.78\n",
       "2018-02-23  22.88  23.37\n",
       "2018-02-22  22.25  22.76\n",
       "2018-02-14  21.49  21.99"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用iloc   == index location\n",
    "# 使用iloc可以通过索引的下标去获取\n",
    "data.iloc[0:100, 0:2].head()   # 所有的切片操作都和numpy类似"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "selected-amsterdam",
   "metadata": {},
   "source": [
    "#### 使用ix进行下标和名称组合做引\n",
    "data.ix[0:10, ['open', 'close']]   \n",
    "####  新版本已删除该函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "plain-halloween",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high\n",
       "2018-02-27  23.53  25.88"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.iloc[0:1, 0:2]   # 不能直接 data[0:1, 0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "weekly-drink",
   "metadata": {},
   "outputs": [],
   "source": [
    "data.close = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "finite-genetics",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-78-6ba3626687f1>:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  data['close']['2018-02-23'] = 4\n"
     ]
    }
   ],
   "source": [
    "data['close']['2018-02-23'] = 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "entitled-chapter",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>1</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>4</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>1</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78      1  22.80   60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37      4  22.71   52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76      1  22.02   36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-03-06  13.17  14.48      1  13.13  179831.72          1.12      8.51   \n",
       "2015-03-05  12.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "2015-03-04  12.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-03  12.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-02  12.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "consolidated-australia",
   "metadata": {},
   "source": [
    "### 排序\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "id": "boolean-humanitarian",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 按照涨跌幅大小进行排序 , 使用ascending指定按照大小排序\n",
    "data.sort_values(by='p_change', ascending=False, inplace=True)   # inplace 是否修改原数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "interpreted-sheep",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-08-28</th>\n",
       "      <td>15.40</td>\n",
       "      <td>16.46</td>\n",
       "      <td>1</td>\n",
       "      <td>15.00</td>\n",
       "      <td>117827.60</td>\n",
       "      <td>1.50</td>\n",
       "      <td>10.03</td>\n",
       "      <td>16.698</td>\n",
       "      <td>18.849</td>\n",
       "      <td>18.853</td>\n",
       "      <td>92680.85</td>\n",
       "      <td>109609.73</td>\n",
       "      <td>107384.89</td>\n",
       "      <td>4.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-05-21</th>\n",
       "      <td>27.50</td>\n",
       "      <td>28.22</td>\n",
       "      <td>1</td>\n",
       "      <td>26.50</td>\n",
       "      <td>121190.11</td>\n",
       "      <td>2.57</td>\n",
       "      <td>10.02</td>\n",
       "      <td>24.508</td>\n",
       "      <td>22.725</td>\n",
       "      <td>22.053</td>\n",
       "      <td>117760.48</td>\n",
       "      <td>103865.87</td>\n",
       "      <td>98766.20</td>\n",
       "      <td>4.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-12-22</th>\n",
       "      <td>18.50</td>\n",
       "      <td>20.42</td>\n",
       "      <td>1</td>\n",
       "      <td>18.45</td>\n",
       "      <td>150470.83</td>\n",
       "      <td>1.86</td>\n",
       "      <td>10.02</td>\n",
       "      <td>18.874</td>\n",
       "      <td>18.775</td>\n",
       "      <td>20.455</td>\n",
       "      <td>59074.51</td>\n",
       "      <td>77760.81</td>\n",
       "      <td>74734.64</td>\n",
       "      <td>3.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-08-04</th>\n",
       "      <td>16.20</td>\n",
       "      <td>17.35</td>\n",
       "      <td>1</td>\n",
       "      <td>15.80</td>\n",
       "      <td>94292.63</td>\n",
       "      <td>1.58</td>\n",
       "      <td>10.02</td>\n",
       "      <td>17.736</td>\n",
       "      <td>19.765</td>\n",
       "      <td>21.454</td>\n",
       "      <td>87169.08</td>\n",
       "      <td>104549.78</td>\n",
       "      <td>123074.95</td>\n",
       "      <td>3.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-07-07</th>\n",
       "      <td>18.66</td>\n",
       "      <td>18.66</td>\n",
       "      <td>1</td>\n",
       "      <td>18.41</td>\n",
       "      <td>48756.55</td>\n",
       "      <td>1.70</td>\n",
       "      <td>10.02</td>\n",
       "      <td>16.206</td>\n",
       "      <td>15.768</td>\n",
       "      <td>15.639</td>\n",
       "      <td>25103.33</td>\n",
       "      <td>30923.60</td>\n",
       "      <td>38378.63</td>\n",
       "      <td>1.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-08-26</th>\n",
       "      <td>17.00</td>\n",
       "      <td>18.35</td>\n",
       "      <td>1</td>\n",
       "      <td>15.56</td>\n",
       "      <td>130318.31</td>\n",
       "      <td>-1.73</td>\n",
       "      <td>-10.01</td>\n",
       "      <td>18.742</td>\n",
       "      <td>20.042</td>\n",
       "      <td>19.087</td>\n",
       "      <td>100097.45</td>\n",
       "      <td>114432.06</td>\n",
       "      <td>102945.90</td>\n",
       "      <td>4.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-07-15</th>\n",
       "      <td>22.78</td>\n",
       "      <td>23.04</td>\n",
       "      <td>1</td>\n",
       "      <td>22.10</td>\n",
       "      <td>85966.42</td>\n",
       "      <td>-2.46</td>\n",
       "      <td>-10.02</td>\n",
       "      <td>24.564</td>\n",
       "      <td>25.197</td>\n",
       "      <td>28.530</td>\n",
       "      <td>158767.95</td>\n",
       "      <td>149753.04</td>\n",
       "      <td>149835.16</td>\n",
       "      <td>2.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-11</th>\n",
       "      <td>16.59</td>\n",
       "      <td>17.24</td>\n",
       "      <td>1</td>\n",
       "      <td>15.90</td>\n",
       "      <td>58036.37</td>\n",
       "      <td>-1.77</td>\n",
       "      <td>-10.02</td>\n",
       "      <td>18.298</td>\n",
       "      <td>20.068</td>\n",
       "      <td>21.648</td>\n",
       "      <td>46971.51</td>\n",
       "      <td>52066.53</td>\n",
       "      <td>58356.88</td>\n",
       "      <td>1.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-09-14</th>\n",
       "      <td>16.62</td>\n",
       "      <td>16.64</td>\n",
       "      <td>1</td>\n",
       "      <td>14.46</td>\n",
       "      <td>139701.77</td>\n",
       "      <td>-1.61</td>\n",
       "      <td>-10.02</td>\n",
       "      <td>14.726</td>\n",
       "      <td>14.363</td>\n",
       "      <td>16.881</td>\n",
       "      <td>98449.69</td>\n",
       "      <td>89159.54</td>\n",
       "      <td>101431.96</td>\n",
       "      <td>4.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-09-01</th>\n",
       "      <td>14.78</td>\n",
       "      <td>14.78</td>\n",
       "      <td>1</td>\n",
       "      <td>13.46</td>\n",
       "      <td>78985.85</td>\n",
       "      <td>-1.50</td>\n",
       "      <td>-10.03</td>\n",
       "      <td>15.080</td>\n",
       "      <td>17.434</td>\n",
       "      <td>18.617</td>\n",
       "      <td>109001.30</td>\n",
       "      <td>103741.22</td>\n",
       "      <td>106218.95</td>\n",
       "      <td>2.70</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-08-28  15.40  16.46      1  15.00  117827.60          1.50     10.03   \n",
       "2015-05-21  27.50  28.22      1  26.50  121190.11          2.57     10.02   \n",
       "2016-12-22  18.50  20.42      1  18.45  150470.83          1.86     10.02   \n",
       "2015-08-04  16.20  17.35      1  15.80   94292.63          1.58     10.02   \n",
       "2016-07-07  18.66  18.66      1  18.41   48756.55          1.70     10.02   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-08-26  17.00  18.35      1  15.56  130318.31         -1.73    -10.01   \n",
       "2015-07-15  22.78  23.04      1  22.10   85966.42         -2.46    -10.02   \n",
       "2016-01-11  16.59  17.24      1  15.90   58036.37         -1.77    -10.02   \n",
       "2015-09-14  16.62  16.64      1  14.46  139701.77         -1.61    -10.02   \n",
       "2015-09-01  14.78  14.78      1  13.46   78985.85         -1.50    -10.03   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-08-28  16.698  18.849  18.853   92680.85  109609.73  107384.89      4.03  \n",
       "2015-05-21  24.508  22.725  22.053  117760.48  103865.87   98766.20      4.15  \n",
       "2016-12-22  18.874  18.775  20.455   59074.51   77760.81   74734.64      3.77  \n",
       "2015-08-04  17.736  19.765  21.454   87169.08  104549.78  123074.95      3.23  \n",
       "2016-07-07  16.206  15.768  15.639   25103.33   30923.60   38378.63      1.67  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2015-08-26  18.742  20.042  19.087  100097.45  114432.06  102945.90      4.46  \n",
       "2015-07-15  24.564  25.197  28.530  158767.95  149753.04  149835.16      2.94  \n",
       "2016-01-11  18.298  20.068  21.648   46971.51   52066.53   58356.88      1.99  \n",
       "2015-09-14  14.726  14.363  16.881   98449.69   89159.54  101431.96      4.78  \n",
       "2015-09-01  15.080  17.434  18.617  109001.30  103741.22  106218.95      2.70  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "burning-antenna",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 按照多个键进行排序\n",
    "data = data.sort_values(by=['open', 'high'])   #  多个键排序，先按第一个，当第一个键的值一样的时候才按第二个键排序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "reduced-security",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-09-02</th>\n",
       "      <td>12.30</td>\n",
       "      <td>14.11</td>\n",
       "      <td>1</td>\n",
       "      <td>12.30</td>\n",
       "      <td>70201.74</td>\n",
       "      <td>-1.10</td>\n",
       "      <td>-8.17</td>\n",
       "      <td>14.440</td>\n",
       "      <td>16.591</td>\n",
       "      <td>18.360</td>\n",
       "      <td>96977.99</td>\n",
       "      <td>98537.72</td>\n",
       "      <td>104567.25</td>\n",
       "      <td>2.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  12.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-09-02  12.30  14.11      1  12.30   70201.74         -1.10     -8.17   \n",
       "2015-03-03  12.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  12.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-05  12.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "2015-09-02  14.440  16.591  18.360   96977.99   98537.72  104567.25      2.40  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  "
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "timely-relations",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>1</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>4</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>1</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  12.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-03-03  12.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  12.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-05  12.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "2015-03-06  13.17  14.48      1  13.13  179831.72          1.12      8.51   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-14  21.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "2018-02-22  22.25  22.76      1  22.02   36105.01          0.36      1.64   \n",
       "2018-02-23  22.88  23.37      4  22.71   52914.01          0.54      2.42   \n",
       "2018-02-26  22.80  23.78      1  22.80   60985.11          0.69      3.02   \n",
       "2018-02-27  23.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sort_index(axis=0, )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "negative-notification",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>21.272706</td>\n",
       "      <td>21.900513</td>\n",
       "      <td>1.004666</td>\n",
       "      <td>20.771835</td>\n",
       "      <td>99905.519114</td>\n",
       "      <td>0.018802</td>\n",
       "      <td>0.190280</td>\n",
       "      <td>21.302362</td>\n",
       "      <td>21.267656</td>\n",
       "      <td>21.200946</td>\n",
       "      <td>100008.642691</td>\n",
       "      <td>100287.542177</td>\n",
       "      <td>100797.518398</td>\n",
       "      <td>2.936190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>3.930973</td>\n",
       "      <td>4.077578</td>\n",
       "      <td>0.118308</td>\n",
       "      <td>3.791968</td>\n",
       "      <td>73879.119354</td>\n",
       "      <td>0.898476</td>\n",
       "      <td>4.079698</td>\n",
       "      <td>3.880640</td>\n",
       "      <td>3.813602</td>\n",
       "      <td>3.686186</td>\n",
       "      <td>62761.578326</td>\n",
       "      <td>56759.082060</td>\n",
       "      <td>50101.575639</td>\n",
       "      <td>2.079375</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>12.250000</td>\n",
       "      <td>12.670000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>12.200000</td>\n",
       "      <td>1158.120000</td>\n",
       "      <td>-3.520000</td>\n",
       "      <td>-10.030000</td>\n",
       "      <td>12.520000</td>\n",
       "      <td>12.520000</td>\n",
       "      <td>12.520000</td>\n",
       "      <td>10804.740000</td>\n",
       "      <td>19130.510000</td>\n",
       "      <td>23311.000000</td>\n",
       "      <td>0.040000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>19.000000</td>\n",
       "      <td>19.500000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>18.525000</td>\n",
       "      <td>48533.210000</td>\n",
       "      <td>-0.390000</td>\n",
       "      <td>-1.850000</td>\n",
       "      <td>18.990000</td>\n",
       "      <td>19.102000</td>\n",
       "      <td>19.275000</td>\n",
       "      <td>55794.985000</td>\n",
       "      <td>59861.955000</td>\n",
       "      <td>64103.675000</td>\n",
       "      <td>1.360000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>21.440000</td>\n",
       "      <td>21.970000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>20.980000</td>\n",
       "      <td>83175.930000</td>\n",
       "      <td>0.050000</td>\n",
       "      <td>0.260000</td>\n",
       "      <td>21.504000</td>\n",
       "      <td>21.623000</td>\n",
       "      <td>21.530000</td>\n",
       "      <td>86133.330000</td>\n",
       "      <td>89234.970000</td>\n",
       "      <td>96291.730000</td>\n",
       "      <td>2.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>23.400000</td>\n",
       "      <td>24.065000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>22.850000</td>\n",
       "      <td>127580.055000</td>\n",
       "      <td>0.455000</td>\n",
       "      <td>2.305000</td>\n",
       "      <td>23.318000</td>\n",
       "      <td>23.098500</td>\n",
       "      <td>23.136000</td>\n",
       "      <td>127655.655000</td>\n",
       "      <td>124693.255000</td>\n",
       "      <td>124001.015000</td>\n",
       "      <td>3.915000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>34.990000</td>\n",
       "      <td>36.350000</td>\n",
       "      <td>4.000000</td>\n",
       "      <td>34.010000</td>\n",
       "      <td>501915.410000</td>\n",
       "      <td>3.030000</td>\n",
       "      <td>10.030000</td>\n",
       "      <td>33.696000</td>\n",
       "      <td>32.186000</td>\n",
       "      <td>29.998000</td>\n",
       "      <td>404443.540000</td>\n",
       "      <td>360028.160000</td>\n",
       "      <td>269280.790000</td>\n",
       "      <td>12.560000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open        high       close         low         volume  \\\n",
       "count  643.000000  643.000000  643.000000  643.000000     643.000000   \n",
       "mean    21.272706   21.900513    1.004666   20.771835   99905.519114   \n",
       "std      3.930973    4.077578    0.118308    3.791968   73879.119354   \n",
       "min     12.250000   12.670000    1.000000   12.200000    1158.120000   \n",
       "25%     19.000000   19.500000    1.000000   18.525000   48533.210000   \n",
       "50%     21.440000   21.970000    1.000000   20.980000   83175.930000   \n",
       "75%     23.400000   24.065000    1.000000   22.850000  127580.055000   \n",
       "max     34.990000   36.350000    4.000000   34.010000  501915.410000   \n",
       "\n",
       "       price_change    p_change         ma5        ma10        ma20  \\\n",
       "count    643.000000  643.000000  643.000000  643.000000  643.000000   \n",
       "mean       0.018802    0.190280   21.302362   21.267656   21.200946   \n",
       "std        0.898476    4.079698    3.880640    3.813602    3.686186   \n",
       "min       -3.520000  -10.030000   12.520000   12.520000   12.520000   \n",
       "25%       -0.390000   -1.850000   18.990000   19.102000   19.275000   \n",
       "50%        0.050000    0.260000   21.504000   21.623000   21.530000   \n",
       "75%        0.455000    2.305000   23.318000   23.098500   23.136000   \n",
       "max        3.030000   10.030000   33.696000   32.186000   29.998000   \n",
       "\n",
       "               v_ma5         v_ma10         v_ma20    turnover  \n",
       "count     643.000000     643.000000     643.000000  643.000000  \n",
       "mean   100008.642691  100287.542177  100797.518398    2.936190  \n",
       "std     62761.578326   56759.082060   50101.575639    2.079375  \n",
       "min     10804.740000   19130.510000   23311.000000    0.040000  \n",
       "25%     55794.985000   59861.955000   64103.675000    1.360000  \n",
       "50%     86133.330000   89234.970000   96291.730000    2.500000  \n",
       "75%    127655.655000  124693.255000  124001.015000    3.915000  \n",
       "max    404443.540000  360028.160000  269280.790000   12.560000  "
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 计算平均值、标准差、最大值、最小值、分位数\n",
    "data.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "infinite-decade",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单独计算\n",
    "data['close'].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "adjacent-sociology",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open                34.990\n",
       "high                36.350\n",
       "close                4.000\n",
       "low                 34.010\n",
       "volume          501915.410\n",
       "price_change         3.030\n",
       "p_change            10.030\n",
       "ma5                 33.696\n",
       "ma10                32.186\n",
       "ma20                29.998\n",
       "v_ma5           404443.540\n",
       "v_ma10          360028.160\n",
       "v_ma20          269280.790\n",
       "turnover            12.560\n",
       "dtype: float64"
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对所有的列进行计算\n",
    "data.max(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "id": "environmental-nepal",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open            2015-06-15\n",
       "high            2015-06-10\n",
       "close           2018-02-23\n",
       "low             2015-06-12\n",
       "volume          2017-10-26\n",
       "price_change    2015-06-09\n",
       "p_change        2015-08-28\n",
       "ma5             2015-06-15\n",
       "ma10            2015-06-18\n",
       "ma20            2015-06-18\n",
       "v_ma5           2017-10-26\n",
       "v_ma10          2017-11-02\n",
       "v_ma20          2017-11-15\n",
       "turnover        2017-10-26\n",
       "dtype: object"
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 求出最大值的位置\n",
    "data.idxmax(axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "computational-event",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open            2015-03-02\n",
       "high            2015-03-02\n",
       "close           2015-03-02\n",
       "low             2015-03-02\n",
       "volume          2016-07-06\n",
       "price_change    2015-06-15\n",
       "p_change        2015-09-01\n",
       "ma5             2015-03-02\n",
       "ma10            2015-03-02\n",
       "ma20            2015-03-02\n",
       "v_ma5           2017-02-03\n",
       "v_ma10          2017-02-03\n",
       "v_ma20          2017-05-23\n",
       "turnover        2016-07-06\n",
       "dtype: object"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 求出最小值的位置\n",
    "data.idxmin(axis=0)   # index == idx"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "supreme-colonial",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 排序之后，进行累计求和\n",
    "data = data.sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "continental-receiver",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.630000000000001"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "2.62 + 1.44 + 1.57"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "rapid-spank",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02    2.62\n",
       "2015-03-03    1.44\n",
       "2015-03-04    1.57\n",
       "2015-03-05    2.02\n",
       "2015-03-06    8.51\n",
       "              ... \n",
       "2018-02-14    2.05\n",
       "2018-02-22    1.64\n",
       "2018-02-23    2.42\n",
       "2018-02-26    3.02\n",
       "2018-02-27    2.68\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#计算累计函数\n",
    "stock_rise = data['p_change']\n",
    "stock_rise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "engaged-effectiveness",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02      2.62\n",
       "2015-03-03      4.06\n",
       "2015-03-04      5.63\n",
       "2015-03-05      7.65\n",
       "2015-03-06     16.16\n",
       "               ...  \n",
       "2018-02-14    112.59\n",
       "2018-02-22    114.23\n",
       "2018-02-23    116.65\n",
       "2018-02-26    119.67\n",
       "2018-02-27    122.35\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_rise.cumsum()   # 累计运算， 从最开始一直加到当前位置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "approved-pavilion",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02    2.62\n",
       "2015-03-03    1.44\n",
       "2015-03-04    1.57\n",
       "2015-03-05    2.02\n",
       "2015-03-06    8.51\n",
       "              ... \n",
       "2018-02-14    2.05\n",
       "2018-02-22    1.64\n",
       "2018-02-23    2.42\n",
       "2018-02-26    3.02\n",
       "2018-02-27    2.68\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_rise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "arabic-wedding",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02     2.62\n",
       "2015-03-03     2.62\n",
       "2015-03-04     2.62\n",
       "2015-03-05     2.62\n",
       "2015-03-06     8.51\n",
       "              ...  \n",
       "2018-02-14    10.03\n",
       "2018-02-22    10.03\n",
       "2018-02-23    10.03\n",
       "2018-02-26    10.03\n",
       "2018-02-27    10.03\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_rise.cummax()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "proof-funds",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD7CAYAAACRxdTpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTA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uCIJQgIu6CIAgliIi7IAhCCSLiLgiCUIKIuAuCIJQg/x/ntr3YsIVV+wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "stock_rise.cumsum().plot()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "conscious-istanbul",
   "metadata": {},
   "source": [
    "### 逻辑运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "embedded-stomach",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-09</th>\n",
       "      <td>14.14</td>\n",
       "      <td>14.85</td>\n",
       "      <td>1</td>\n",
       "      <td>13.80</td>\n",
       "      <td>144945.66</td>\n",
       "      <td>0.03</td>\n",
       "      <td>0.21</td>\n",
       "      <td>13.470</td>\n",
       "      <td>13.312</td>\n",
       "      <td>13.312</td>\n",
       "      <td>124820.96</td>\n",
       "      <td>120066.09</td>\n",
       "      <td>120066.09</td>\n",
       "      <td>4.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-11</th>\n",
       "      <td>14.80</td>\n",
       "      <td>15.08</td>\n",
       "      <td>1</td>\n",
       "      <td>14.14</td>\n",
       "      <td>119708.43</td>\n",
       "      <td>-0.35</td>\n",
       "      <td>-2.39</td>\n",
       "      <td>14.140</td>\n",
       "      <td>13.603</td>\n",
       "      <td>13.603</td>\n",
       "      <td>127775.94</td>\n",
       "      <td>117664.81</td>\n",
       "      <td>117664.81</td>\n",
       "      <td>4.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-12</th>\n",
       "      <td>14.11</td>\n",
       "      <td>14.80</td>\n",
       "      <td>1</td>\n",
       "      <td>13.95</td>\n",
       "      <td>84978.37</td>\n",
       "      <td>-0.19</td>\n",
       "      <td>-1.33</td>\n",
       "      <td>14.330</td>\n",
       "      <td>13.659</td>\n",
       "      <td>13.659</td>\n",
       "      <td>126135.54</td>\n",
       "      <td>114032.98</td>\n",
       "      <td>114032.98</td>\n",
       "      <td>2.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-07</th>\n",
       "      <td>22.69</td>\n",
       "      <td>23.11</td>\n",
       "      <td>1</td>\n",
       "      <td>21.29</td>\n",
       "      <td>53853.25</td>\n",
       "      <td>-0.50</td>\n",
       "      <td>-2.24</td>\n",
       "      <td>22.480</td>\n",
       "      <td>23.258</td>\n",
       "      <td>23.929</td>\n",
       "      <td>52281.28</td>\n",
       "      <td>56315.11</td>\n",
       "      <td>74925.33</td>\n",
       "      <td>1.35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-08</th>\n",
       "      <td>21.79</td>\n",
       "      <td>22.09</td>\n",
       "      <td>1</td>\n",
       "      <td>21.75</td>\n",
       "      <td>27068.16</td>\n",
       "      <td>0.09</td>\n",
       "      <td>0.41</td>\n",
       "      <td>22.372</td>\n",
       "      <td>23.009</td>\n",
       "      <td>23.839</td>\n",
       "      <td>44411.98</td>\n",
       "      <td>48612.16</td>\n",
       "      <td>73852.45</td>\n",
       "      <td>0.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-09</th>\n",
       "      <td>21.20</td>\n",
       "      <td>21.46</td>\n",
       "      <td>1</td>\n",
       "      <td>20.19</td>\n",
       "      <td>54304.01</td>\n",
       "      <td>-1.50</td>\n",
       "      <td>-6.86</td>\n",
       "      <td>21.920</td>\n",
       "      <td>22.596</td>\n",
       "      <td>23.645</td>\n",
       "      <td>48624.36</td>\n",
       "      <td>48982.38</td>\n",
       "      <td>70552.47</td>\n",
       "      <td>1.36</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-13</th>\n",
       "      <td>21.40</td>\n",
       "      <td>21.90</td>\n",
       "      <td>1</td>\n",
       "      <td>21.31</td>\n",
       "      <td>30802.45</td>\n",
       "      <td>0.28</td>\n",
       "      <td>1.32</td>\n",
       "      <td>21.342</td>\n",
       "      <td>22.103</td>\n",
       "      <td>23.387</td>\n",
       "      <td>39694.65</td>\n",
       "      <td>45518.14</td>\n",
       "      <td>65161.68</td>\n",
       "      <td>0.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>460 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-03  12.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  12.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-09  14.14  14.85      1  13.80  144945.66          0.03      0.21   \n",
       "2015-03-11  14.80  15.08      1  14.14  119708.43         -0.35     -2.39   \n",
       "2015-03-12  14.11  14.80      1  13.95   84978.37         -0.19     -1.33   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-07  22.69  23.11      1  21.29   53853.25         -0.50     -2.24   \n",
       "2018-02-08  21.79  22.09      1  21.75   27068.16          0.09      0.41   \n",
       "2018-02-09  21.20  21.46      1  20.19   54304.01         -1.50     -6.86   \n",
       "2018-02-13  21.40  21.90      1  21.31   30802.45          0.28      1.32   \n",
       "2018-02-22  22.25  22.76      1  22.02   36105.01          0.36      1.64   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-09  13.470  13.312  13.312  124820.96  120066.09  120066.09      4.96  \n",
       "2015-03-11  14.140  13.603  13.603  127775.94  117664.81  117664.81      4.10  \n",
       "2015-03-12  14.330  13.659  13.659  126135.54  114032.98  114032.98      2.91  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-02-07  22.480  23.258  23.929   52281.28   56315.11   74925.33      1.35  \n",
       "2018-02-08  22.372  23.009  23.839   44411.98   48612.16   73852.45      0.68  \n",
       "2018-02-09  21.920  22.596  23.645   48624.36   48982.38   70552.47      1.36  \n",
       "2018-02-13  21.342  22.103  23.387   39694.65   45518.14   65161.68      0.77  \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90  \n",
       "\n",
       "[460 rows x 14 columns]"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 进行逻辑判断\n",
    "# 用true false进行标记，逻辑判断的结果可以作为筛选的依据\n",
    "data[data['p_change'] < 2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "aware-technical",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-30</th>\n",
       "      <td>15.99</td>\n",
       "      <td>16.63</td>\n",
       "      <td>1</td>\n",
       "      <td>15.99</td>\n",
       "      <td>85090.45</td>\n",
       "      <td>0.65</td>\n",
       "      <td>4.12</td>\n",
       "      <td>15.620</td>\n",
       "      <td>15.469</td>\n",
       "      <td>14.722</td>\n",
       "      <td>108176.96</td>\n",
       "      <td>108109.99</td>\n",
       "      <td>108345.78</td>\n",
       "      <td>2.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-07</th>\n",
       "      <td>16.54</td>\n",
       "      <td>17.98</td>\n",
       "      <td>1</td>\n",
       "      <td>16.50</td>\n",
       "      <td>122471.85</td>\n",
       "      <td>0.88</td>\n",
       "      <td>5.28</td>\n",
       "      <td>16.620</td>\n",
       "      <td>16.120</td>\n",
       "      <td>15.510</td>\n",
       "      <td>86769.62</td>\n",
       "      <td>97473.29</td>\n",
       "      <td>98832.94</td>\n",
       "      <td>4.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-08</th>\n",
       "      <td>17.60</td>\n",
       "      <td>18.53</td>\n",
       "      <td>1</td>\n",
       "      <td>17.60</td>\n",
       "      <td>157725.97</td>\n",
       "      <td>0.88</td>\n",
       "      <td>5.02</td>\n",
       "      <td>17.070</td>\n",
       "      <td>16.394</td>\n",
       "      <td>15.698</td>\n",
       "      <td>101421.29</td>\n",
       "      <td>97906.88</td>\n",
       "      <td>101658.57</td>\n",
       "      <td>5.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-09</th>\n",
       "      <td>18.28</td>\n",
       "      <td>19.89</td>\n",
       "      <td>1</td>\n",
       "      <td>18.02</td>\n",
       "      <td>183119.05</td>\n",
       "      <td>1.20</td>\n",
       "      <td>6.51</td>\n",
       "      <td>17.736</td>\n",
       "      <td>16.826</td>\n",
       "      <td>15.964</td>\n",
       "      <td>124323.21</td>\n",
       "      <td>106501.34</td>\n",
       "      <td>104829.10</td>\n",
       "      <td>6.27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-13</th>\n",
       "      <td>19.60</td>\n",
       "      <td>21.30</td>\n",
       "      <td>1</td>\n",
       "      <td>19.50</td>\n",
       "      <td>171822.69</td>\n",
       "      <td>1.70</td>\n",
       "      <td>8.75</td>\n",
       "      <td>19.228</td>\n",
       "      <td>17.812</td>\n",
       "      <td>16.563</td>\n",
       "      <td>149620.34</td>\n",
       "      <td>114456.84</td>\n",
       "      <td>111752.31</td>\n",
       "      <td>5.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-12</th>\n",
       "      <td>20.70</td>\n",
       "      <td>21.40</td>\n",
       "      <td>1</td>\n",
       "      <td>20.63</td>\n",
       "      <td>32445.39</td>\n",
       "      <td>0.82</td>\n",
       "      <td>4.03</td>\n",
       "      <td>21.504</td>\n",
       "      <td>22.338</td>\n",
       "      <td>23.533</td>\n",
       "      <td>44645.16</td>\n",
       "      <td>45679.94</td>\n",
       "      <td>68686.33</td>\n",
       "      <td>0.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>4</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>1</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>161 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-30  15.99  16.63      1  15.99   85090.45          0.65      4.12   \n",
       "2015-04-07  16.54  17.98      1  16.50  122471.85          0.88      5.28   \n",
       "2015-04-08  17.60  18.53      1  17.60  157725.97          0.88      5.02   \n",
       "2015-04-09  18.28  19.89      1  18.02  183119.05          1.20      6.51   \n",
       "2015-04-13  19.60  21.30      1  19.50  171822.69          1.70      8.75   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-12  20.70  21.40      1  20.63   32445.39          0.82      4.03   \n",
       "2018-02-14  21.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "2018-02-23  22.88  23.37      4  22.71   52914.01          0.54      2.42   \n",
       "2018-02-26  22.80  23.78      1  22.80   60985.11          0.69      3.02   \n",
       "2018-02-27  23.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-30  15.620  15.469  14.722  108176.96  108109.99  108345.78      2.91  \n",
       "2015-04-07  16.620  16.120  15.510   86769.62   97473.29   98832.94      4.19  \n",
       "2015-04-08  17.070  16.394  15.698  101421.29   97906.88  101658.57      5.40  \n",
       "2015-04-09  17.736  16.826  15.964  124323.21  106501.34  104829.10      6.27  \n",
       "2015-04-13  19.228  17.812  16.563  149620.34  114456.84  111752.31      5.88  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-02-12  21.504  22.338  23.533   44645.16   45679.94   68686.33      0.81  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "\n",
       "[161 rows x 14 columns]"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 完成一个符合逻辑判断， p_change > 2, open > 15\n",
    "data[(data['p_change'] > 2) & (data['open'] > 15)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "official-compound",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-12</th>\n",
       "      <td>14.11</td>\n",
       "      <td>14.80</td>\n",
       "      <td>1</td>\n",
       "      <td>13.95</td>\n",
       "      <td>84978.37</td>\n",
       "      <td>-0.19</td>\n",
       "      <td>-1.33</td>\n",
       "      <td>14.330</td>\n",
       "      <td>13.659</td>\n",
       "      <td>13.659</td>\n",
       "      <td>126135.54</td>\n",
       "      <td>114032.98</td>\n",
       "      <td>114032.98</td>\n",
       "      <td>2.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-26</th>\n",
       "      <td>15.14</td>\n",
       "      <td>15.35</td>\n",
       "      <td>1</td>\n",
       "      <td>14.91</td>\n",
       "      <td>84877.75</td>\n",
       "      <td>-0.37</td>\n",
       "      <td>-2.42</td>\n",
       "      <td>15.326</td>\n",
       "      <td>15.184</td>\n",
       "      <td>14.462</td>\n",
       "      <td>100340.74</td>\n",
       "      <td>103146.79</td>\n",
       "      <td>108303.41</td>\n",
       "      <td>2.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-30</th>\n",
       "      <td>15.99</td>\n",
       "      <td>16.63</td>\n",
       "      <td>1</td>\n",
       "      <td>15.99</td>\n",
       "      <td>85090.45</td>\n",
       "      <td>0.65</td>\n",
       "      <td>4.12</td>\n",
       "      <td>15.620</td>\n",
       "      <td>15.469</td>\n",
       "      <td>14.722</td>\n",
       "      <td>108176.96</td>\n",
       "      <td>108109.99</td>\n",
       "      <td>108345.78</td>\n",
       "      <td>2.91</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-07</th>\n",
       "      <td>16.54</td>\n",
       "      <td>17.98</td>\n",
       "      <td>1</td>\n",
       "      <td>16.50</td>\n",
       "      <td>122471.85</td>\n",
       "      <td>0.88</td>\n",
       "      <td>5.28</td>\n",
       "      <td>16.620</td>\n",
       "      <td>16.120</td>\n",
       "      <td>15.510</td>\n",
       "      <td>86769.62</td>\n",
       "      <td>97473.29</td>\n",
       "      <td>98832.94</td>\n",
       "      <td>4.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-25</th>\n",
       "      <td>23.07</td>\n",
       "      <td>24.20</td>\n",
       "      <td>1</td>\n",
       "      <td>22.64</td>\n",
       "      <td>167489.48</td>\n",
       "      <td>0.67</td>\n",
       "      <td>2.91</td>\n",
       "      <td>23.042</td>\n",
       "      <td>22.759</td>\n",
       "      <td>22.199</td>\n",
       "      <td>137135.54</td>\n",
       "      <td>156145.65</td>\n",
       "      <td>166607.70</td>\n",
       "      <td>4.19</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-12  14.11  14.80      1  13.95   84978.37         -0.19     -1.33   \n",
       "2015-03-26  15.14  15.35      1  14.91   84877.75         -0.37     -2.42   \n",
       "2015-03-30  15.99  16.63      1  15.99   85090.45          0.65      4.12   \n",
       "2015-04-07  16.54  17.98      1  16.50  122471.85          0.88      5.28   \n",
       "2017-07-25  23.07  24.20      1  22.64  167489.48          0.67      2.91   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-12  14.330  13.659  13.659  126135.54  114032.98  114032.98      2.91  \n",
       "2015-03-26  15.326  15.184  14.462  100340.74  103146.79  108303.41      2.91  \n",
       "2015-03-30  15.620  15.469  14.722  108176.96  108109.99  108345.78      2.91  \n",
       "2015-04-07  16.620  16.120  15.510   86769.62   97473.29   98832.94      4.19  \n",
       "2017-07-25  23.042  22.759  22.199  137135.54  156145.65  166607.70      4.19  "
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data[data['turnover'].isin([4.19,2.91])]   # 数据库里面的 in 操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "stunning-logging",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>1</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  12.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-03-03  12.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  12.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-05  12.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "2015-03-06  13.17  14.48      1  13.13  179831.72          1.12      8.51   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  "
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "younger-traffic",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02    13.25\n",
       "2015-03-03    13.52\n",
       "2015-03-04    13.80\n",
       "2015-03-05    13.88\n",
       "2015-03-06    14.17\n",
       "              ...  \n",
       "2018-02-14    22.49\n",
       "2018-02-22    23.25\n",
       "2018-02-23    23.88\n",
       "2018-02-26    23.80\n",
       "2018-02-27    24.53\n",
       "Name: open, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 进行数学运算 加上具体的一个数字\n",
    "data['open'].add(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "respiratory-mechanics",
   "metadata": {},
   "outputs": [],
   "source": [
    "data['open'] = data['open'] + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "important-program",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 自己求出每天 close- open价格差\n",
    "# 筛选两列数据\n",
    "close = data['close']\n",
    "open1 = data['open']\n",
    "# 默认按照索引对齐\n",
    "data['m_price_change'] = close.sub(open1)   ##  m_price_change 在原来的数据里面是没有的，但我们可以直接添加\n",
    "#  当某一列不存在的时候，我们直接给这一列设置值， 将会增加一列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "spanish-casting",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "      <th>m_price_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>13.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "      <td>-12.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>13.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "      <td>-12.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>13.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "      <td>-12.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>13.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "      <td>-12.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>14.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>1</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "      <td>-13.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>22.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "      <td>-21.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>23.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "      <td>-22.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>23.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>4</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "      <td>-19.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>23.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>1</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "      <td>-22.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>24.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "      <td>-23.53</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 15 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  13.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-03-03  13.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  13.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-05  13.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "2015-03-06  14.17  14.48      1  13.13  179831.72          1.12      8.51   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-14  22.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "2018-02-22  23.25  22.76      1  22.02   36105.01          0.36      1.64   \n",
       "2018-02-23  23.88  23.37      4  22.71   52914.01          0.54      2.42   \n",
       "2018-02-26  23.80  23.78      1  22.80   60985.11          0.69      3.02   \n",
       "2018-02-27  24.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \\\n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30   \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76   \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30   \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19   \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16   \n",
       "...            ...     ...     ...        ...        ...        ...       ...   \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58   \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90   \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32   \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53   \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39   \n",
       "\n",
       "            m_price_change  \n",
       "2015-03-02          -12.25  \n",
       "2015-03-03          -12.52  \n",
       "2015-03-04          -12.80  \n",
       "2015-03-05          -12.88  \n",
       "2015-03-06          -13.17  \n",
       "...                    ...  \n",
       "2018-02-14          -21.49  \n",
       "2018-02-22          -22.25  \n",
       "2018-02-23          -19.88  \n",
       "2018-02-26          -22.80  \n",
       "2018-02-27          -23.53  \n",
       "\n",
       "[643 rows x 15 columns]"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fallen-optimum",
   "metadata": {},
   "source": [
    "### 文件读取与存储"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "tropical-registration",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "presidential-gambling",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('data/stock_day.csv', usecols=['open', 'high', 'p_change'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "floating-motivation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>p_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>2.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>3.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>2.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>2.05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  p_change\n",
       "2018-02-27  23.53  25.88      2.68\n",
       "2018-02-26  22.80  23.78      3.02\n",
       "2018-02-23  22.88  23.37      2.42\n",
       "2018-02-22  22.25  22.76      1.64\n",
       "2018-02-14  21.49  21.99      2.05"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "numerous-louisville",
   "metadata": {},
   "outputs": [],
   "source": [
    "data.head().to_csv('data/stock_5.csv', index_label=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "known-anger",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>p_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>2.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>3.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>2.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>2.05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  p_change\n",
       "2018-02-27  23.53  25.88      2.68\n",
       "2018-02-26  22.80  23.78      3.02\n",
       "2018-02-23  22.88  23.37      2.42\n",
       "2018-02-22  22.25  22.76      1.64\n",
       "2018-02-14  21.49  21.99      2.05"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv('data/stock_5.csv', index_col=[0])    # 写进去和读出来的数据不匹配，怎么处理？\n",
    "# 两种方式解决索引列名被写进文件的问题\n",
    "# 1. 在to_csv() 增加 index_label=False\n",
    "# 2. 在读取的时候，指定索引列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "hourly-option",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'F:\\\\龙坡\\\\代码\\\\ai2021\\\\移动2033'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "direct-force",
   "metadata": {},
   "source": [
    "#### hdf文件的读写"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "commercial-yeast",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\tables\\path.py:155: NaturalNameWarning: object name is not a valid Python identifier: '2033'; it does not match the pattern ``^[a-zA-Z_][a-zA-Z0-9_]*$``; you will not be able to use natural naming to access this object; using ``getattr()`` will still work, though\n",
      "  check_attribute_name(name)\n"
     ]
    }
   ],
   "source": [
    "data.to_hdf('data/stock_5_hdf.h5', key='2033')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "robust-latin",
   "metadata": {},
   "source": [
    "处理没有 tables 模块的错误\n",
    "![](images/Snipaste_2021-10-21_08-59-14.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "fuzzy-adrian",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>p_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>2.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>3.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>2.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>2.05</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>8.51</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>2.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>2.62</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  p_change\n",
       "2018-02-27  23.53  25.88      2.68\n",
       "2018-02-26  22.80  23.78      3.02\n",
       "2018-02-23  22.88  23.37      2.42\n",
       "2018-02-22  22.25  22.76      1.64\n",
       "2018-02-14  21.49  21.99      2.05\n",
       "...           ...    ...       ...\n",
       "2015-03-06  13.17  14.48      8.51\n",
       "2015-03-05  12.88  13.45      2.02\n",
       "2015-03-04  12.80  12.92      1.57\n",
       "2015-03-03  12.52  13.06      1.44\n",
       "2015-03-02  12.25  12.67      2.62\n",
       "\n",
       "[643 rows x 3 columns]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_hdf('data/stock_5_hdf.h5')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "municipal-tract",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "manual-hearing",
   "metadata": {},
   "outputs": [],
   "source": [
    "movie = pd.read_csv('data/movie.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "apparent-instruction",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Rank</th>\n",
       "      <th>Title</th>\n",
       "      <th>Genre</th>\n",
       "      <th>Description</th>\n",
       "      <th>Director</th>\n",
       "      <th>Actors</th>\n",
       "      <th>Year</th>\n",
       "      <th>Runtime (Minutes)</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Votes</th>\n",
       "      <th>Revenue (Millions)</th>\n",
       "      <th>Metascore</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Guardians of the Galaxy</td>\n",
       "      <td>Action,Adventure,Sci-Fi</td>\n",
       "      <td>A group of intergalactic criminals are forced ...</td>\n",
       "      <td>James Gunn</td>\n",
       "      <td>Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...</td>\n",
       "      <td>2014</td>\n",
       "      <td>121</td>\n",
       "      <td>8.1</td>\n",
       "      <td>757074</td>\n",
       "      <td>333.13</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Prometheus</td>\n",
       "      <td>Adventure,Mystery,Sci-Fi</td>\n",
       "      <td>Following clues to the origin of mankind, a te...</td>\n",
       "      <td>Ridley Scott</td>\n",
       "      <td>Noomi Rapace, Logan Marshall-Green, Michael Fa...</td>\n",
       "      <td>2012</td>\n",
       "      <td>124</td>\n",
       "      <td>7.0</td>\n",
       "      <td>485820</td>\n",
       "      <td>126.46</td>\n",
       "      <td>65.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Split</td>\n",
       "      <td>Horror,Thriller</td>\n",
       "      <td>Three girls are kidnapped by a man with a diag...</td>\n",
       "      <td>M. Night Shyamalan</td>\n",
       "      <td>James McAvoy, Anya Taylor-Joy, Haley Lu Richar...</td>\n",
       "      <td>2016</td>\n",
       "      <td>117</td>\n",
       "      <td>7.3</td>\n",
       "      <td>157606</td>\n",
       "      <td>138.12</td>\n",
       "      <td>62.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Sing</td>\n",
       "      <td>Animation,Comedy,Family</td>\n",
       "      <td>In a city of humanoid animals, a hustling thea...</td>\n",
       "      <td>Christophe Lourdelet</td>\n",
       "      <td>Matthew McConaughey,Reese Witherspoon, Seth Ma...</td>\n",
       "      <td>2016</td>\n",
       "      <td>108</td>\n",
       "      <td>7.2</td>\n",
       "      <td>60545</td>\n",
       "      <td>270.32</td>\n",
       "      <td>59.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Suicide Squad</td>\n",
       "      <td>Action,Adventure,Fantasy</td>\n",
       "      <td>A secret government agency recruits some of th...</td>\n",
       "      <td>David Ayer</td>\n",
       "      <td>Will Smith, Jared Leto, Margot Robbie, Viola D...</td>\n",
       "      <td>2016</td>\n",
       "      <td>123</td>\n",
       "      <td>6.2</td>\n",
       "      <td>393727</td>\n",
       "      <td>325.02</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>996</td>\n",
       "      <td>Secret in Their Eyes</td>\n",
       "      <td>Crime,Drama,Mystery</td>\n",
       "      <td>A tight-knit team of rising investigators, alo...</td>\n",
       "      <td>Billy Ray</td>\n",
       "      <td>Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...</td>\n",
       "      <td>2015</td>\n",
       "      <td>111</td>\n",
       "      <td>6.2</td>\n",
       "      <td>27585</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>997</td>\n",
       "      <td>Hostel: Part II</td>\n",
       "      <td>Horror</td>\n",
       "      <td>Three American college students studying abroa...</td>\n",
       "      <td>Eli Roth</td>\n",
       "      <td>Lauren German, Heather Matarazzo, Bijou Philli...</td>\n",
       "      <td>2007</td>\n",
       "      <td>94</td>\n",
       "      <td>5.5</td>\n",
       "      <td>73152</td>\n",
       "      <td>17.54</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>998</td>\n",
       "      <td>Step Up 2: The Streets</td>\n",
       "      <td>Drama,Music,Romance</td>\n",
       "      <td>Romantic sparks occur between two dance studen...</td>\n",
       "      <td>Jon M. Chu</td>\n",
       "      <td>Robert Hoffman, Briana Evigan, Cassie Ventura,...</td>\n",
       "      <td>2008</td>\n",
       "      <td>98</td>\n",
       "      <td>6.2</td>\n",
       "      <td>70699</td>\n",
       "      <td>58.01</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>999</td>\n",
       "      <td>Search Party</td>\n",
       "      <td>Adventure,Comedy</td>\n",
       "      <td>A pair of friends embark on a mission to reuni...</td>\n",
       "      <td>Scot Armstrong</td>\n",
       "      <td>Adam Pally, T.J. Miller, Thomas Middleditch,Sh...</td>\n",
       "      <td>2014</td>\n",
       "      <td>93</td>\n",
       "      <td>5.6</td>\n",
       "      <td>4881</td>\n",
       "      <td>NaN</td>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>1000</td>\n",
       "      <td>Nine Lives</td>\n",
       "      <td>Comedy,Family,Fantasy</td>\n",
       "      <td>A stuffy businessman finds himself trapped ins...</td>\n",
       "      <td>Barry Sonnenfeld</td>\n",
       "      <td>Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...</td>\n",
       "      <td>2016</td>\n",
       "      <td>87</td>\n",
       "      <td>5.3</td>\n",
       "      <td>12435</td>\n",
       "      <td>19.64</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Rank                    Title                     Genre  \\\n",
       "0       1  Guardians of the Galaxy   Action,Adventure,Sci-Fi   \n",
       "1       2               Prometheus  Adventure,Mystery,Sci-Fi   \n",
       "2       3                    Split           Horror,Thriller   \n",
       "3       4                     Sing   Animation,Comedy,Family   \n",
       "4       5            Suicide Squad  Action,Adventure,Fantasy   \n",
       "..    ...                      ...                       ...   \n",
       "995   996     Secret in Their Eyes       Crime,Drama,Mystery   \n",
       "996   997          Hostel: Part II                    Horror   \n",
       "997   998   Step Up 2: The Streets       Drama,Music,Romance   \n",
       "998   999             Search Party          Adventure,Comedy   \n",
       "999  1000               Nine Lives     Comedy,Family,Fantasy   \n",
       "\n",
       "                                           Description              Director  \\\n",
       "0    A group of intergalactic criminals are forced ...            James Gunn   \n",
       "1    Following clues to the origin of mankind, a te...          Ridley Scott   \n",
       "2    Three girls are kidnapped by a man with a diag...    M. Night Shyamalan   \n",
       "3    In a city of humanoid animals, a hustling thea...  Christophe Lourdelet   \n",
       "4    A secret government agency recruits some of th...            David Ayer   \n",
       "..                                                 ...                   ...   \n",
       "995  A tight-knit team of rising investigators, alo...             Billy Ray   \n",
       "996  Three American college students studying abroa...              Eli Roth   \n",
       "997  Romantic sparks occur between two dance studen...            Jon M. Chu   \n",
       "998  A pair of friends embark on a mission to reuni...        Scot Armstrong   \n",
       "999  A stuffy businessman finds himself trapped ins...      Barry Sonnenfeld   \n",
       "\n",
       "                                                Actors  Year  \\\n",
       "0    Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...  2014   \n",
       "1    Noomi Rapace, Logan Marshall-Green, Michael Fa...  2012   \n",
       "2    James McAvoy, Anya Taylor-Joy, Haley Lu Richar...  2016   \n",
       "3    Matthew McConaughey,Reese Witherspoon, Seth Ma...  2016   \n",
       "4    Will Smith, Jared Leto, Margot Robbie, Viola D...  2016   \n",
       "..                                                 ...   ...   \n",
       "995  Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...  2015   \n",
       "996  Lauren German, Heather Matarazzo, Bijou Philli...  2007   \n",
       "997  Robert Hoffman, Briana Evigan, Cassie Ventura,...  2008   \n",
       "998  Adam Pally, T.J. Miller, Thomas Middleditch,Sh...  2014   \n",
       "999  Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...  2016   \n",
       "\n",
       "     Runtime (Minutes)  Rating   Votes  Revenue (Millions)  Metascore  \n",
       "0                  121     8.1  757074              333.13       76.0  \n",
       "1                  124     7.0  485820              126.46       65.0  \n",
       "2                  117     7.3  157606              138.12       62.0  \n",
       "3                  108     7.2   60545              270.32       59.0  \n",
       "4                  123     6.2  393727              325.02       40.0  \n",
       "..                 ...     ...     ...                 ...        ...  \n",
       "995                111     6.2   27585                 NaN       45.0  \n",
       "996                 94     5.5   73152               17.54       46.0  \n",
       "997                 98     6.2   70699               58.01       50.0  \n",
       "998                 93     5.6    4881                 NaN       22.0  \n",
       "999                 87     5.3   12435               19.64       11.0  \n",
       "\n",
       "[1000 rows x 12 columns]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "numerous-livestock",
   "metadata": {},
   "source": [
    "### 如何判断是否有缺失值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "varied-compound",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Rank</th>\n",
       "      <th>Title</th>\n",
       "      <th>Genre</th>\n",
       "      <th>Description</th>\n",
       "      <th>Director</th>\n",
       "      <th>Actors</th>\n",
       "      <th>Year</th>\n",
       "      <th>Runtime (Minutes)</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Votes</th>\n",
       "      <th>Revenue (Millions)</th>\n",
       "      <th>Metascore</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>False</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Rank  Title  Genre  Description  Director  Actors  Year  \\\n",
       "0    True   True   True         True      True    True  True   \n",
       "1    True   True   True         True      True    True  True   \n",
       "2    True   True   True         True      True    True  True   \n",
       "3    True   True   True         True      True    True  True   \n",
       "4    True   True   True         True      True    True  True   \n",
       "..    ...    ...    ...          ...       ...     ...   ...   \n",
       "995  True   True   True         True      True    True  True   \n",
       "996  True   True   True         True      True    True  True   \n",
       "997  True   True   True         True      True    True  True   \n",
       "998  True   True   True         True      True    True  True   \n",
       "999  True   True   True         True      True    True  True   \n",
       "\n",
       "     Runtime (Minutes)  Rating  Votes  Revenue (Millions)  Metascore  \n",
       "0                 True    True   True                True       True  \n",
       "1                 True    True   True                True       True  \n",
       "2                 True    True   True                True       True  \n",
       "3                 True    True   True                True       True  \n",
       "4                 True    True   True                True       True  \n",
       "..                 ...     ...    ...                 ...        ...  \n",
       "995               True    True   True               False       True  \n",
       "996               True    True   True                True       True  \n",
       "997               True    True   True                True       True  \n",
       "998               True    True   True               False       True  \n",
       "999               True    True   True                True       True  \n",
       "\n",
       "[1000 rows x 12 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.notnull(movie)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "orange-community",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Rank                   True\n",
       "Title                  True\n",
       "Genre                  True\n",
       "Description            True\n",
       "Director               True\n",
       "Actors                 True\n",
       "Year                   True\n",
       "Runtime (Minutes)      True\n",
       "Rating                 True\n",
       "Votes                  True\n",
       "Revenue (Millions)    False\n",
       "Metascore             False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.all(pd.notnull(movie), axis=0)  # 最终我们想看到 如果结果为True则代表没有缺失值了"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "another-think",
   "metadata": {},
   "source": [
    "### 1. 填充NaN，   填充成0    平均值  最大值 等等"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "authentic-rates",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "82.95637614678898"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie['Revenue (Millions)'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "chemical-baptist",
   "metadata": {},
   "outputs": [],
   "source": [
    "values = {'Revenue (Millions)': movie['Revenue (Millions)'].mean(),\n",
    "          'Metascore': movie['Metascore'].mean()}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "other-viking",
   "metadata": {},
   "outputs": [],
   "source": [
    "movie.fillna(value=values, inplace=True)  \n",
    "# inplace 标记是否修改原始数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "unavailable-ireland",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Rank</th>\n",
       "      <th>Title</th>\n",
       "      <th>Genre</th>\n",
       "      <th>Description</th>\n",
       "      <th>Director</th>\n",
       "      <th>Actors</th>\n",
       "      <th>Year</th>\n",
       "      <th>Runtime (Minutes)</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Votes</th>\n",
       "      <th>Revenue (Millions)</th>\n",
       "      <th>Metascore</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Guardians of the Galaxy</td>\n",
       "      <td>Action,Adventure,Sci-Fi</td>\n",
       "      <td>A group of intergalactic criminals are forced ...</td>\n",
       "      <td>James Gunn</td>\n",
       "      <td>Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...</td>\n",
       "      <td>2014</td>\n",
       "      <td>121</td>\n",
       "      <td>8.1</td>\n",
       "      <td>757074</td>\n",
       "      <td>333.130000</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Prometheus</td>\n",
       "      <td>Adventure,Mystery,Sci-Fi</td>\n",
       "      <td>Following clues to the origin of mankind, a te...</td>\n",
       "      <td>Ridley Scott</td>\n",
       "      <td>Noomi Rapace, Logan Marshall-Green, Michael Fa...</td>\n",
       "      <td>2012</td>\n",
       "      <td>124</td>\n",
       "      <td>7.0</td>\n",
       "      <td>485820</td>\n",
       "      <td>126.460000</td>\n",
       "      <td>65.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Split</td>\n",
       "      <td>Horror,Thriller</td>\n",
       "      <td>Three girls are kidnapped by a man with a diag...</td>\n",
       "      <td>M. Night Shyamalan</td>\n",
       "      <td>James McAvoy, Anya Taylor-Joy, Haley Lu Richar...</td>\n",
       "      <td>2016</td>\n",
       "      <td>117</td>\n",
       "      <td>7.3</td>\n",
       "      <td>157606</td>\n",
       "      <td>138.120000</td>\n",
       "      <td>62.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Sing</td>\n",
       "      <td>Animation,Comedy,Family</td>\n",
       "      <td>In a city of humanoid animals, a hustling thea...</td>\n",
       "      <td>Christophe Lourdelet</td>\n",
       "      <td>Matthew McConaughey,Reese Witherspoon, Seth Ma...</td>\n",
       "      <td>2016</td>\n",
       "      <td>108</td>\n",
       "      <td>7.2</td>\n",
       "      <td>60545</td>\n",
       "      <td>270.320000</td>\n",
       "      <td>59.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Suicide Squad</td>\n",
       "      <td>Action,Adventure,Fantasy</td>\n",
       "      <td>A secret government agency recruits some of th...</td>\n",
       "      <td>David Ayer</td>\n",
       "      <td>Will Smith, Jared Leto, Margot Robbie, Viola D...</td>\n",
       "      <td>2016</td>\n",
       "      <td>123</td>\n",
       "      <td>6.2</td>\n",
       "      <td>393727</td>\n",
       "      <td>325.020000</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>996</td>\n",
       "      <td>Secret in Their Eyes</td>\n",
       "      <td>Crime,Drama,Mystery</td>\n",
       "      <td>A tight-knit team of rising investigators, alo...</td>\n",
       "      <td>Billy Ray</td>\n",
       "      <td>Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...</td>\n",
       "      <td>2015</td>\n",
       "      <td>111</td>\n",
       "      <td>6.2</td>\n",
       "      <td>27585</td>\n",
       "      <td>82.956376</td>\n",
       "      <td>45.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>997</td>\n",
       "      <td>Hostel: Part II</td>\n",
       "      <td>Horror</td>\n",
       "      <td>Three American college students studying abroa...</td>\n",
       "      <td>Eli Roth</td>\n",
       "      <td>Lauren German, Heather Matarazzo, Bijou Philli...</td>\n",
       "      <td>2007</td>\n",
       "      <td>94</td>\n",
       "      <td>5.5</td>\n",
       "      <td>73152</td>\n",
       "      <td>17.540000</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>998</td>\n",
       "      <td>Step Up 2: The Streets</td>\n",
       "      <td>Drama,Music,Romance</td>\n",
       "      <td>Romantic sparks occur between two dance studen...</td>\n",
       "      <td>Jon M. Chu</td>\n",
       "      <td>Robert Hoffman, Briana Evigan, Cassie Ventura,...</td>\n",
       "      <td>2008</td>\n",
       "      <td>98</td>\n",
       "      <td>6.2</td>\n",
       "      <td>70699</td>\n",
       "      <td>58.010000</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>999</td>\n",
       "      <td>Search Party</td>\n",
       "      <td>Adventure,Comedy</td>\n",
       "      <td>A pair of friends embark on a mission to reuni...</td>\n",
       "      <td>Scot Armstrong</td>\n",
       "      <td>Adam Pally, T.J. Miller, Thomas Middleditch,Sh...</td>\n",
       "      <td>2014</td>\n",
       "      <td>93</td>\n",
       "      <td>5.6</td>\n",
       "      <td>4881</td>\n",
       "      <td>82.956376</td>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>1000</td>\n",
       "      <td>Nine Lives</td>\n",
       "      <td>Comedy,Family,Fantasy</td>\n",
       "      <td>A stuffy businessman finds himself trapped ins...</td>\n",
       "      <td>Barry Sonnenfeld</td>\n",
       "      <td>Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...</td>\n",
       "      <td>2016</td>\n",
       "      <td>87</td>\n",
       "      <td>5.3</td>\n",
       "      <td>12435</td>\n",
       "      <td>19.640000</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Rank                    Title                     Genre  \\\n",
       "0       1  Guardians of the Galaxy   Action,Adventure,Sci-Fi   \n",
       "1       2               Prometheus  Adventure,Mystery,Sci-Fi   \n",
       "2       3                    Split           Horror,Thriller   \n",
       "3       4                     Sing   Animation,Comedy,Family   \n",
       "4       5            Suicide Squad  Action,Adventure,Fantasy   \n",
       "..    ...                      ...                       ...   \n",
       "995   996     Secret in Their Eyes       Crime,Drama,Mystery   \n",
       "996   997          Hostel: Part II                    Horror   \n",
       "997   998   Step Up 2: The Streets       Drama,Music,Romance   \n",
       "998   999             Search Party          Adventure,Comedy   \n",
       "999  1000               Nine Lives     Comedy,Family,Fantasy   \n",
       "\n",
       "                                           Description              Director  \\\n",
       "0    A group of intergalactic criminals are forced ...            James Gunn   \n",
       "1    Following clues to the origin of mankind, a te...          Ridley Scott   \n",
       "2    Three girls are kidnapped by a man with a diag...    M. Night Shyamalan   \n",
       "3    In a city of humanoid animals, a hustling thea...  Christophe Lourdelet   \n",
       "4    A secret government agency recruits some of th...            David Ayer   \n",
       "..                                                 ...                   ...   \n",
       "995  A tight-knit team of rising investigators, alo...             Billy Ray   \n",
       "996  Three American college students studying abroa...              Eli Roth   \n",
       "997  Romantic sparks occur between two dance studen...            Jon M. Chu   \n",
       "998  A pair of friends embark on a mission to reuni...        Scot Armstrong   \n",
       "999  A stuffy businessman finds himself trapped ins...      Barry Sonnenfeld   \n",
       "\n",
       "                                                Actors  Year  \\\n",
       "0    Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...  2014   \n",
       "1    Noomi Rapace, Logan Marshall-Green, Michael Fa...  2012   \n",
       "2    James McAvoy, Anya Taylor-Joy, Haley Lu Richar...  2016   \n",
       "3    Matthew McConaughey,Reese Witherspoon, Seth Ma...  2016   \n",
       "4    Will Smith, Jared Leto, Margot Robbie, Viola D...  2016   \n",
       "..                                                 ...   ...   \n",
       "995  Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...  2015   \n",
       "996  Lauren German, Heather Matarazzo, Bijou Philli...  2007   \n",
       "997  Robert Hoffman, Briana Evigan, Cassie Ventura,...  2008   \n",
       "998  Adam Pally, T.J. Miller, Thomas Middleditch,Sh...  2014   \n",
       "999  Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...  2016   \n",
       "\n",
       "     Runtime (Minutes)  Rating   Votes  Revenue (Millions)  Metascore  \n",
       "0                  121     8.1  757074          333.130000       76.0  \n",
       "1                  124     7.0  485820          126.460000       65.0  \n",
       "2                  117     7.3  157606          138.120000       62.0  \n",
       "3                  108     7.2   60545          270.320000       59.0  \n",
       "4                  123     6.2  393727          325.020000       40.0  \n",
       "..                 ...     ...     ...                 ...        ...  \n",
       "995                111     6.2   27585           82.956376       45.0  \n",
       "996                 94     5.5   73152           17.540000       46.0  \n",
       "997                 98     6.2   70699           58.010000       50.0  \n",
       "998                 93     5.6    4881           82.956376       22.0  \n",
       "999                 87     5.3   12435           19.640000       11.0  \n",
       "\n",
       "[1000 rows x 12 columns]"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "polyphonic-sleeping",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Rank                  True\n",
       "Title                 True\n",
       "Genre                 True\n",
       "Description           True\n",
       "Director              True\n",
       "Actors                True\n",
       "Year                  True\n",
       "Runtime (Minutes)     True\n",
       "Rating                True\n",
       "Votes                 True\n",
       "Revenue (Millions)    True\n",
       "Metascore             True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 对票房填充了平均值后， 再来看下票房这里一列是否还为False\n",
    "np.all(pd.notnull(movie), axis=0) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "separate-robertson",
   "metadata": {},
   "outputs": [],
   "source": [
    "movie = pd.read_csv('data/movie.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "incredible-senegal",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1000, 12)"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "curious-short",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Rank                   True\n",
       "Title                  True\n",
       "Genre                  True\n",
       "Description            True\n",
       "Director               True\n",
       "Actors                 True\n",
       "Year                   True\n",
       "Runtime (Minutes)      True\n",
       "Rating                 True\n",
       "Votes                  True\n",
       "Revenue (Millions)    False\n",
       "Metascore             False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.all(pd.notnull(movie), axis=0) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "understanding-apollo",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Rank</th>\n",
       "      <th>Title</th>\n",
       "      <th>Genre</th>\n",
       "      <th>Description</th>\n",
       "      <th>Director</th>\n",
       "      <th>Actors</th>\n",
       "      <th>Year</th>\n",
       "      <th>Runtime (Minutes)</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Votes</th>\n",
       "      <th>Revenue (Millions)</th>\n",
       "      <th>Metascore</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Guardians of the Galaxy</td>\n",
       "      <td>Action,Adventure,Sci-Fi</td>\n",
       "      <td>A group of intergalactic criminals are forced ...</td>\n",
       "      <td>James Gunn</td>\n",
       "      <td>Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...</td>\n",
       "      <td>2014</td>\n",
       "      <td>121</td>\n",
       "      <td>8.1</td>\n",
       "      <td>757074</td>\n",
       "      <td>333.13</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Prometheus</td>\n",
       "      <td>Adventure,Mystery,Sci-Fi</td>\n",
       "      <td>Following clues to the origin of mankind, a te...</td>\n",
       "      <td>Ridley Scott</td>\n",
       "      <td>Noomi Rapace, Logan Marshall-Green, Michael Fa...</td>\n",
       "      <td>2012</td>\n",
       "      <td>124</td>\n",
       "      <td>7.0</td>\n",
       "      <td>485820</td>\n",
       "      <td>126.46</td>\n",
       "      <td>65.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Split</td>\n",
       "      <td>Horror,Thriller</td>\n",
       "      <td>Three girls are kidnapped by a man with a diag...</td>\n",
       "      <td>M. Night Shyamalan</td>\n",
       "      <td>James McAvoy, Anya Taylor-Joy, Haley Lu Richar...</td>\n",
       "      <td>2016</td>\n",
       "      <td>117</td>\n",
       "      <td>7.3</td>\n",
       "      <td>157606</td>\n",
       "      <td>138.12</td>\n",
       "      <td>62.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Sing</td>\n",
       "      <td>Animation,Comedy,Family</td>\n",
       "      <td>In a city of humanoid animals, a hustling thea...</td>\n",
       "      <td>Christophe Lourdelet</td>\n",
       "      <td>Matthew McConaughey,Reese Witherspoon, Seth Ma...</td>\n",
       "      <td>2016</td>\n",
       "      <td>108</td>\n",
       "      <td>7.2</td>\n",
       "      <td>60545</td>\n",
       "      <td>270.32</td>\n",
       "      <td>59.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Suicide Squad</td>\n",
       "      <td>Action,Adventure,Fantasy</td>\n",
       "      <td>A secret government agency recruits some of th...</td>\n",
       "      <td>David Ayer</td>\n",
       "      <td>Will Smith, Jared Leto, Margot Robbie, Viola D...</td>\n",
       "      <td>2016</td>\n",
       "      <td>123</td>\n",
       "      <td>6.2</td>\n",
       "      <td>393727</td>\n",
       "      <td>325.02</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>993</th>\n",
       "      <td>994</td>\n",
       "      <td>Resident Evil: Afterlife</td>\n",
       "      <td>Action,Adventure,Horror</td>\n",
       "      <td>While still out to destroy the evil Umbrella C...</td>\n",
       "      <td>Paul W.S. Anderson</td>\n",
       "      <td>Milla Jovovich, Ali Larter, Wentworth Miller,K...</td>\n",
       "      <td>2010</td>\n",
       "      <td>97</td>\n",
       "      <td>5.9</td>\n",
       "      <td>140900</td>\n",
       "      <td>60.13</td>\n",
       "      <td>37.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>994</th>\n",
       "      <td>995</td>\n",
       "      <td>Project X</td>\n",
       "      <td>Comedy</td>\n",
       "      <td>3 high school seniors throw a birthday party t...</td>\n",
       "      <td>Nima Nourizadeh</td>\n",
       "      <td>Thomas Mann, Oliver Cooper, Jonathan Daniel Br...</td>\n",
       "      <td>2012</td>\n",
       "      <td>88</td>\n",
       "      <td>6.7</td>\n",
       "      <td>164088</td>\n",
       "      <td>54.72</td>\n",
       "      <td>48.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>997</td>\n",
       "      <td>Hostel: Part II</td>\n",
       "      <td>Horror</td>\n",
       "      <td>Three American college students studying abroa...</td>\n",
       "      <td>Eli Roth</td>\n",
       "      <td>Lauren German, Heather Matarazzo, Bijou Philli...</td>\n",
       "      <td>2007</td>\n",
       "      <td>94</td>\n",
       "      <td>5.5</td>\n",
       "      <td>73152</td>\n",
       "      <td>17.54</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>998</td>\n",
       "      <td>Step Up 2: The Streets</td>\n",
       "      <td>Drama,Music,Romance</td>\n",
       "      <td>Romantic sparks occur between two dance studen...</td>\n",
       "      <td>Jon M. Chu</td>\n",
       "      <td>Robert Hoffman, Briana Evigan, Cassie Ventura,...</td>\n",
       "      <td>2008</td>\n",
       "      <td>98</td>\n",
       "      <td>6.2</td>\n",
       "      <td>70699</td>\n",
       "      <td>58.01</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>1000</td>\n",
       "      <td>Nine Lives</td>\n",
       "      <td>Comedy,Family,Fantasy</td>\n",
       "      <td>A stuffy businessman finds himself trapped ins...</td>\n",
       "      <td>Barry Sonnenfeld</td>\n",
       "      <td>Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...</td>\n",
       "      <td>2016</td>\n",
       "      <td>87</td>\n",
       "      <td>5.3</td>\n",
       "      <td>12435</td>\n",
       "      <td>19.64</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>838 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Rank                     Title                     Genre  \\\n",
       "0       1   Guardians of the Galaxy   Action,Adventure,Sci-Fi   \n",
       "1       2                Prometheus  Adventure,Mystery,Sci-Fi   \n",
       "2       3                     Split           Horror,Thriller   \n",
       "3       4                      Sing   Animation,Comedy,Family   \n",
       "4       5             Suicide Squad  Action,Adventure,Fantasy   \n",
       "..    ...                       ...                       ...   \n",
       "993   994  Resident Evil: Afterlife   Action,Adventure,Horror   \n",
       "994   995                 Project X                    Comedy   \n",
       "996   997           Hostel: Part II                    Horror   \n",
       "997   998    Step Up 2: The Streets       Drama,Music,Romance   \n",
       "999  1000                Nine Lives     Comedy,Family,Fantasy   \n",
       "\n",
       "                                           Description              Director  \\\n",
       "0    A group of intergalactic criminals are forced ...            James Gunn   \n",
       "1    Following clues to the origin of mankind, a te...          Ridley Scott   \n",
       "2    Three girls are kidnapped by a man with a diag...    M. Night Shyamalan   \n",
       "3    In a city of humanoid animals, a hustling thea...  Christophe Lourdelet   \n",
       "4    A secret government agency recruits some of th...            David Ayer   \n",
       "..                                                 ...                   ...   \n",
       "993  While still out to destroy the evil Umbrella C...    Paul W.S. Anderson   \n",
       "994  3 high school seniors throw a birthday party t...       Nima Nourizadeh   \n",
       "996  Three American college students studying abroa...              Eli Roth   \n",
       "997  Romantic sparks occur between two dance studen...            Jon M. Chu   \n",
       "999  A stuffy businessman finds himself trapped ins...      Barry Sonnenfeld   \n",
       "\n",
       "                                                Actors  Year  \\\n",
       "0    Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...  2014   \n",
       "1    Noomi Rapace, Logan Marshall-Green, Michael Fa...  2012   \n",
       "2    James McAvoy, Anya Taylor-Joy, Haley Lu Richar...  2016   \n",
       "3    Matthew McConaughey,Reese Witherspoon, Seth Ma...  2016   \n",
       "4    Will Smith, Jared Leto, Margot Robbie, Viola D...  2016   \n",
       "..                                                 ...   ...   \n",
       "993  Milla Jovovich, Ali Larter, Wentworth Miller,K...  2010   \n",
       "994  Thomas Mann, Oliver Cooper, Jonathan Daniel Br...  2012   \n",
       "996  Lauren German, Heather Matarazzo, Bijou Philli...  2007   \n",
       "997  Robert Hoffman, Briana Evigan, Cassie Ventura,...  2008   \n",
       "999  Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...  2016   \n",
       "\n",
       "     Runtime (Minutes)  Rating   Votes  Revenue (Millions)  Metascore  \n",
       "0                  121     8.1  757074              333.13       76.0  \n",
       "1                  124     7.0  485820              126.46       65.0  \n",
       "2                  117     7.3  157606              138.12       62.0  \n",
       "3                  108     7.2   60545              270.32       59.0  \n",
       "4                  123     6.2  393727              325.02       40.0  \n",
       "..                 ...     ...     ...                 ...        ...  \n",
       "993                 97     5.9  140900               60.13       37.0  \n",
       "994                 88     6.7  164088               54.72       48.0  \n",
       "996                 94     5.5   73152               17.54       46.0  \n",
       "997                 98     6.2   70699               58.01       50.0  \n",
       "999                 87     5.3   12435               19.64       11.0  \n",
       "\n",
       "[838 rows x 12 columns]"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "historical-amendment",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('data/stock_5.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "double-lighter",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>p_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>2.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>?</td>\n",
       "      <td>23.78</td>\n",
       "      <td>3.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>$</td>\n",
       "      <td>2.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>2.05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  p_change\n",
       "2018-02-27  23.53  25.88      2.68\n",
       "2018-02-26      ?  23.78      3.02\n",
       "2018-02-23  22.88      $      2.42\n",
       "2018-02-22  22.25  22.76      1.64\n",
       "2018-02-14  21.49  21.99      2.05"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "breeding-change",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = data.replace({'?':np.NaN, '$': np.NaN})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "floral-pottery",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>p_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>2.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>NaN</td>\n",
       "      <td>23.78</td>\n",
       "      <td>3.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>2.05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  p_change\n",
       "2018-02-27  23.53  25.88      2.68\n",
       "2018-02-26    NaN  23.78      3.02\n",
       "2018-02-23  22.88    NaN      2.42\n",
       "2018-02-22  22.25  22.76      1.64\n",
       "2018-02-14  21.49  21.99      2.05"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "suitable-visibility",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>p_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>2.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>2.05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  p_change\n",
       "2018-02-27  23.53  25.88      2.68\n",
       "2018-02-22  22.25  22.76      1.64\n",
       "2018-02-14  21.49  21.99      2.05"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "designing-lightning",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = data.astype(np.float64)  # 当我们读取进来的数据类型不是我们希望的，那么我们需要提前做转换，否则后续会出错"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "smaller-talent",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open        float64\n",
       "high        float64\n",
       "p_change    float64\n",
       "dtype: object"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "looking-collect",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "23.6025"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['high'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "pharmaceutical-diving",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>p_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.8800</td>\n",
       "      <td>2.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.25</td>\n",
       "      <td>23.7800</td>\n",
       "      <td>3.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.6025</td>\n",
       "      <td>2.42</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.7600</td>\n",
       "      <td>1.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.9900</td>\n",
       "      <td>2.05</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open     high  p_change\n",
       "2018-02-27  23.53  25.8800      2.68\n",
       "2018-02-26  22.25  23.7800      3.02\n",
       "2018-02-23  22.88  23.6025      2.42\n",
       "2018-02-22  22.25  22.7600      1.64\n",
       "2018-02-14  21.49  21.9900      2.05"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.fillna({'open': 22.25, 'high': data['high'].mean()})"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fleet-feelings",
   "metadata": {},
   "source": [
    "### 数据离散化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "associate-packing",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv(\"data/stock_day.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "nonprofit-popularity",
   "metadata": {},
   "outputs": [],
   "source": [
    "p_change= data['p_change']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "personalized-lafayette",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    2.68\n",
       "2018-02-26    3.02\n",
       "2018-02-23    2.42\n",
       "2018-02-22    1.64\n",
       "2018-02-14    2.05\n",
       "              ... \n",
       "2015-03-06    8.51\n",
       "2015-03-05    2.02\n",
       "2015-03-04    1.57\n",
       "2015-03-03    1.44\n",
       "2015-03-02    2.62\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p_change"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "plain-announcement",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "another-glory",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAAASTElEQVR4nO3dfYxldX3H8fe3+JAtQ8DtuuO6JV1NCJE6qboTamvbzAS1SBtXmmokxLLBZjUpRNNt0lUTS0JMtC2a1NgHLARsqNMmQiGAVUoYiUm1nSULs2SloG5blu1uKDgwltiOfvvHPSt3rvfOfTx37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Wok7Tb2AM/Mtw7wtF4v2z8RETsy83j1Me5kHTVGxEuA3wJ2b7CMp6rfJyPiDhofmYYKpF7bLiI+D9zdZlIttz/oob2uAn4TuCSrE4BtljHy9mqjl9e/KbeIiIiX0gjv2zLz9tbpzYGemfdGxJ9HxLbMrPXGTT1sl828pcY7gIcy80TrhM1qr0ovOTSSdivlFMpdwHsj4uUR8Roaf0n/pcN8V1WPrwI6HdEP663AtzLzyXYTI+LsiDjn1GMaX+QdbjfvqLScd7y8w/rGfvuDiLgU+EPgnZn5Px3mGVd79fL67wJ+p+pd8WZg5dTH4bpU36fcBBzJzE93mOdV1XxExMU03rv/XXNdvWyXsbdXk46fgjejvZr0kkOjeS/W/S1tn9/oXk7jL9MPgBPAV5qmfYzGt7aPAe9oGv/XVD1WgJ8B7gcer35vranOW4APtox7NXBv9fi1NL5Vfhh4lMaphLrb7m+AZeCRakfY0VpXNXwZjV4O3x5TXU/QONd3qPr5y81sr3avH/jgqe1J46Pt56rpyzT1hqqxpl+h8fH5kaZ2uqylrmuqtnmYxpfBvzyGutpul81ur2q9P00jkM9tGjf29qLxB+Q48H9Vdr2/Uw7V8V70UnpJKlQpp1AkSS0McEkqlAEuSYUywCWpUAa4JBXKAJekQhngklSo/wf/wkuzwELvxQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "p_change.hist(bins=80)   # 直方图， 划分成80个区间\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "thick-matrix",
   "metadata": {},
   "outputs": [],
   "source": [
    "qcut = pd.qcut(np.abs(p_change), 10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "great-cleaners",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27      (2.1, 2.802]\n",
       "2018-02-26    (2.802, 3.662]\n",
       "2018-02-23      (2.1, 2.802]\n",
       "2018-02-22       (1.57, 2.1]\n",
       "2018-02-14       (1.57, 2.1]\n",
       "                   ...      \n",
       "2015-03-06    (7.198, 10.03]\n",
       "2015-03-05       (1.57, 2.1]\n",
       "2015-03-04     (1.106, 1.57]\n",
       "2015-03-03     (1.106, 1.57]\n",
       "2015-03-02      (2.1, 2.802]\n",
       "Name: p_change, Length: 643, dtype: category\n",
       "Categories (10, interval[float64]): [(-0.001, 0.332] < (0.332, 0.73] < (0.73, 1.106] < (1.106, 1.57] ... (2.802, 3.662] < (3.662, 5.11] < (5.11, 7.198] < (7.198, 10.03]]"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qcut"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "canadian-edition",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1.106, 1.57]      67\n",
       "(-0.001, 0.332]    65\n",
       "(0.332, 0.73]      65\n",
       "(3.662, 5.11]      65\n",
       "(7.198, 10.03]     65\n",
       "(1.57, 2.1]        64\n",
       "(2.802, 3.662]     64\n",
       "(0.73, 1.106]      63\n",
       "(5.11, 7.198]      63\n",
       "(2.1, 2.802]       62\n",
       "Name: p_change, dtype: int64"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qcut.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "pregnant-nebraska",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 自己指定分组区间\n",
    "bins = [-100, -7, -5, -3, 0, 3, 5, 7, 100]\n",
    "p_counts = pd.cut(p_change, bins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "detected-forge",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-100, -7]     34\n",
       "(-7, -5]       28\n",
       "(-5, -3]       51\n",
       "(-3, 0]       188\n",
       "(0, 3]        215\n",
       "(3, 5]         57\n",
       "(5, 7]         35\n",
       "(7, 100]       35\n",
       "Name: p_change, dtype: int64"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p_counts.value_counts().sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "subjective-judges",
   "metadata": {},
   "outputs": [],
   "source": [
    "dummaries = pd.get_dummies(p_counts, prefix=\"rise\")   # 根据划分的区间，获取哑变量矩阵"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "annual-mobility",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27      (0, 3]\n",
       "2018-02-26      (3, 5]\n",
       "2018-02-23      (0, 3]\n",
       "2018-02-22      (0, 3]\n",
       "2018-02-14      (0, 3]\n",
       "                ...   \n",
       "2015-03-06    (7, 100]\n",
       "2015-03-05      (0, 3]\n",
       "2015-03-04      (0, 3]\n",
       "2015-03-03      (0, 3]\n",
       "2015-03-02      (0, 3]\n",
       "Name: p_change, Length: 643, dtype: category\n",
       "Categories (8, interval[int64]): [(-100, -7] < (-7, -5] < (-5, -3] < (-3, 0] < (0, 3] < (3, 5] < (5, 7] < (7, 100]]"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p_counts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "sixth-mining",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>rise_(-100, -7]</th>\n",
       "      <th>rise_(-7, -5]</th>\n",
       "      <th>rise_(-5, -3]</th>\n",
       "      <th>rise_(-3, 0]</th>\n",
       "      <th>rise_(0, 3]</th>\n",
       "      <th>rise_(3, 5]</th>\n",
       "      <th>rise_(5, 7]</th>\n",
       "      <th>rise_(7, 100]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            rise_(-100, -7]  rise_(-7, -5]  rise_(-5, -3]  rise_(-3, 0]  \\\n",
       "2018-02-27                0              0              0             0   \n",
       "2018-02-26                0              0              0             0   \n",
       "2018-02-23                0              0              0             0   \n",
       "2018-02-22                0              0              0             0   \n",
       "2018-02-14                0              0              0             0   \n",
       "...                     ...            ...            ...           ...   \n",
       "2015-03-06                0              0              0             0   \n",
       "2015-03-05                0              0              0             0   \n",
       "2015-03-04                0              0              0             0   \n",
       "2015-03-03                0              0              0             0   \n",
       "2015-03-02                0              0              0             0   \n",
       "\n",
       "            rise_(0, 3]  rise_(3, 5]  rise_(5, 7]  rise_(7, 100]  \n",
       "2018-02-27            1            0            0              0  \n",
       "2018-02-26            0            1            0              0  \n",
       "2018-02-23            1            0            0              0  \n",
       "2018-02-22            1            0            0              0  \n",
       "2018-02-14            1            0            0              0  \n",
       "...                 ...          ...          ...            ...  \n",
       "2015-03-06            0            0            0              1  \n",
       "2015-03-05            1            0            0              0  \n",
       "2015-03-04            1            0            0              0  \n",
       "2015-03-03            1            0            0              0  \n",
       "2015-03-02            1            0            0              0  \n",
       "\n",
       "[643 rows x 8 columns]"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dummaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "distinguished-health",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张三</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>李四</th>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别\n",
       "张三   1\n",
       "李四   2"
      ]
     },
     "execution_count": 78,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(data = [[1],[2]], index=['张三','李四'], columns=['性别'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "standard-indie",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别男</th>\n",
       "      <th>性别女</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张三</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>李四</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别男  性别女\n",
       "张三    1    0\n",
       "李四    0    1"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame(data = [[1, 0],[0,1]], index=['张三','李四'], columns=['性别男','性别女'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "turkish-strategy",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 讲男 女 变成独立事件，互不相干扰。  方便后续进入矩阵进行运算"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "inside-edward",
   "metadata": {},
   "outputs": [],
   "source": [
    "man_high = np.random.normal(165, 5, size=100)  # 模拟身高数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "collect-record",
   "metadata": {},
   "outputs": [],
   "source": [
    "man_high = man_high.round(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "selected-country",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([160.7, 166.2, 164. , 168.2, 169.3, 165.3, 159.8, 176.3, 162.5,\n",
       "       164. , 163. , 164. , 168.8, 175.4, 165.4, 163.6, 164. , 169. ,\n",
       "       176. , 159.7, 162.8, 162. , 161.6, 161.1, 165.8, 171.2, 166.2,\n",
       "       156.9, 159.1, 165.8, 168. , 167.4, 164.6, 168.4, 166. , 161.3,\n",
       "       162.1, 170.8, 165.9, 153.7, 158.9, 179.8, 161.7, 163.3, 156.4,\n",
       "       156.9, 171. , 163.6, 171.1, 158.2, 165.3, 166.6, 159.3, 162.7,\n",
       "       165. , 155.6, 174. , 163.6, 171.6, 168.6, 166.6, 170.3, 163.8,\n",
       "       159.6, 160.4, 155.7, 163.6, 165.8, 166. , 164.7, 161.5, 158.7,\n",
       "       167.3, 166.6, 170.7, 157.1, 167. , 167.7, 163. , 173.4, 159.8,\n",
       "       169.2, 167.6, 166.6, 161.9, 171.1, 167.1, 159.7, 166.3, 163.3,\n",
       "       167.2, 172.7, 159.9, 168.1, 158.4, 158.3, 166.9, 164.2, 163.1,\n",
       "       163.9])"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "man_high"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "attempted-brave",
   "metadata": {},
   "outputs": [],
   "source": [
    "man_names = ['张'+str(i) for i in range(100)] "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "id": "industrial-principal",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "module 'pandas' has no attribute 'Serices'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-109-f7fe138d2bf1>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mman_high_df\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mSerices\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mman_high\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mindex\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mman_names\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcolumns\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'身高'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\__init__.py\u001b[0m in \u001b[0;36m__getattr__\u001b[1;34m(name)\u001b[0m\n\u001b[0;32m    242\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0m_SparseArray\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    243\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 244\u001b[1;33m     \u001b[1;32mraise\u001b[0m \u001b[0mAttributeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mf\"module 'pandas' has no attribute '{name}'\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    245\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    246\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mAttributeError\u001b[0m: module 'pandas' has no attribute 'Serices'"
     ]
    }
   ],
   "source": [
    "man_high_df = pd.DataFrame(data = man_high, index = man_names, columns=['身高'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "japanese-judge",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "张0     160.7\n",
       "张1     166.2\n",
       "张2     164.0\n",
       "张3     168.2\n",
       "张4     169.3\n",
       "       ...  \n",
       "张95    158.3\n",
       "张96    166.9\n",
       "张97    164.2\n",
       "张98    163.1\n",
       "张99    163.9\n",
       "Name: 身高, Length: 100, dtype: float64"
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "man_high_df['身高']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "id": "tested-wallpaper",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(身高    179.8\n",
       " dtype: float64,\n",
       " 身高    153.7\n",
       " dtype: float64)"
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "man_high_df.max(), man_high_df.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "emerging-oliver",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "constitutional-automation",
   "metadata": {},
   "outputs": [],
   "source": [
    "bins = [150, 160, 170, 180]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "formal-killer",
   "metadata": {},
   "outputs": [],
   "source": [
    "p_counts = pd.cut(man_high_df['身高'], bins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "former-watson",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(160, 170]    65\n",
       "(150, 160]    20\n",
       "(170, 180]    15\n",
       "Name: 身高, dtype: int64"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p_counts.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "magnetic-sensitivity",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>身高__(150, 160]</th>\n",
       "      <th>身高__(160, 170]</th>\n",
       "      <th>身高__(170, 180]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张0</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张1</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张2</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张3</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张4</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张95</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张96</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张97</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张98</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张99</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     身高__(150, 160]  身高__(160, 170]  身高__(170, 180]\n",
       "张0                0               1               0\n",
       "张1                0               1               0\n",
       "张2                0               1               0\n",
       "张3                0               1               0\n",
       "张4                0               1               0\n",
       "..              ...             ...             ...\n",
       "张95               1               0               0\n",
       "张96               0               1               0\n",
       "张97               0               1               0\n",
       "张98               0               1               0\n",
       "张99               0               1               0\n",
       "\n",
       "[100 rows x 3 columns]"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.get_dummies(p_counts, prefix='身高_')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "animal-mississippi",
   "metadata": {},
   "source": [
    "### 数据合并操作"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dress-touch",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "young-billy",
   "metadata": {},
   "outputs": [],
   "source": [
    "left = pd.DataFrame({'key1': ['K0', 'K0', 'K1', 'K2'],\n",
    "                        'key2': ['K0', 'K1', 'K0', 'K1'],\n",
    "                        'A': ['A0', 'A1', 'A2', 'A3'],\n",
    "                        'B': ['B0', 'B1', 'B2', 'B3']})\n",
    "\n",
    "right = pd.DataFrame({'key1': ['K0', 'K1', 'K1', 'K2'],\n",
    "                        'key2': ['K0', 'K0', 'K0', 'K0'],\n",
    "                        'C': ['C0', 'C1', 'C2', 'C3'],\n",
    "                        'D': ['D0', 'D1', 'D2', 'D3']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "organized-patrol",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K0</td>\n",
       "      <td>K1</td>\n",
       "      <td>A1</td>\n",
       "      <td>B1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K2</td>\n",
       "      <td>K1</td>\n",
       "      <td>A3</td>\n",
       "      <td>B3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   A   B\n",
       "0   K0   K0  A0  B0\n",
       "1   K0   K1  A1  B1\n",
       "2   K1   K0  A2  B2\n",
       "3   K2   K1  A3  B3"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "left"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "stunning-variance",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K2</td>\n",
       "      <td>K0</td>\n",
       "      <td>C3</td>\n",
       "      <td>D3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   C   D\n",
       "0   K0   K0  C0  D0\n",
       "1   K1   K0  C1  D1\n",
       "2   K1   K0  C2  D2\n",
       "3   K2   K0  C3  D3"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "right"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "heated-colorado",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   A   B   C   D\n",
       "0   K0   K0  A0  B0  C0  D0\n",
       "1   K1   K0  A2  B2  C1  D1\n",
       "2   K1   K0  A2  B2  C2  D2"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 默认内连接   内连接是左右两边存在相同的key值，则数据保留\n",
    "pd.merge(left, right, on=['key1', 'key2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "accompanied-december",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K0</td>\n",
       "      <td>K1</td>\n",
       "      <td>A1</td>\n",
       "      <td>B1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>K2</td>\n",
       "      <td>K1</td>\n",
       "      <td>A3</td>\n",
       "      <td>B3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   A   B    C    D\n",
       "0   K0   K0  A0  B0   C0   D0\n",
       "1   K0   K1  A1  B1  NaN  NaN\n",
       "2   K1   K0  A2  B2   C1   D1\n",
       "3   K1   K0  A2  B2   C2   D2\n",
       "4   K2   K1  A3  B3  NaN  NaN"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 左连接， 以左边为基准，左边存在的数据一定保留，右边如果没有对应的key的数据，则置空\n",
    "pd.merge(left, right, how='left', on=['key1', 'key2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "auburn-roller",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K2</td>\n",
       "      <td>K0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>C3</td>\n",
       "      <td>D3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2    A    B   C   D\n",
       "0   K0   K0   A0   B0  C0  D0\n",
       "1   K1   K0   A2   B2  C1  D1\n",
       "2   K1   K0   A2   B2  C2  D2\n",
       "3   K2   K0  NaN  NaN  C3  D3"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 右连接， 以右边为基准，右边存在的数据一定保留，左边如果没有对应的key的数据，则置空\n",
    "pd.merge(left, right, how='right', on=['key1', 'key2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "twelve-plasma",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K0</td>\n",
       "      <td>K1</td>\n",
       "      <td>A1</td>\n",
       "      <td>B1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>K2</td>\n",
       "      <td>K1</td>\n",
       "      <td>A3</td>\n",
       "      <td>B3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>K2</td>\n",
       "      <td>K0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>C3</td>\n",
       "      <td>D3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2    A    B    C    D\n",
       "0   K0   K0   A0   B0   C0   D0\n",
       "1   K0   K1   A1   B1  NaN  NaN\n",
       "2   K1   K0   A2   B2   C1   D1\n",
       "3   K1   K0   A2   B2   C2   D2\n",
       "4   K2   K1   A3   B3  NaN  NaN\n",
       "5   K2   K0  NaN  NaN   C3   D3"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 外连接， 两边数据都保留，没有对应的key的那边置空\n",
    "pd.merge(left, right, how='outer', on=['key1', 'key2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "searching-system",
   "metadata": {},
   "outputs": [],
   "source": [
    "col =pd.DataFrame({'color': ['white','red','green','red','green'], 'object': ['pen','pencil','pencil','ashtray','pen'],'price1':[5.56,4.20,1.30,0.56,2.75],'price2':[4.75,4.12,1.60,0.75,3.15]})\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "dynamic-season",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>object</th>\n",
       "      <th>price1</th>\n",
       "      <th>price2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>white</td>\n",
       "      <td>pen</td>\n",
       "      <td>5.56</td>\n",
       "      <td>4.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>red</td>\n",
       "      <td>pencil</td>\n",
       "      <td>4.20</td>\n",
       "      <td>4.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>green</td>\n",
       "      <td>pencil</td>\n",
       "      <td>1.30</td>\n",
       "      <td>1.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>red</td>\n",
       "      <td>ashtray</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>green</td>\n",
       "      <td>pen</td>\n",
       "      <td>2.75</td>\n",
       "      <td>3.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color   object  price1  price2\n",
       "0  white      pen    5.56    4.75\n",
       "1    red   pencil    4.20    4.12\n",
       "2  green   pencil    1.30    1.60\n",
       "3    red  ashtray    0.56    0.75\n",
       "4  green      pen    2.75    3.15"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "reduced-rental",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "color\n",
       "green    2.025\n",
       "red      2.380\n",
       "white    5.560\n",
       "Name: price1, dtype: float64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分组，求平均值\n",
    "col.groupby(['color'])['price1'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "upset-preference",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "color\n",
       "green    2.025\n",
       "red      2.380\n",
       "white    5.560\n",
       "Name: price1, dtype: float64"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col['price1'].groupby(col['color']).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "improved-directive",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>green</td>\n",
       "      <td>2.025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>red</td>\n",
       "      <td>2.380</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>white</td>\n",
       "      <td>5.560</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color  price1\n",
       "0  green   2.025\n",
       "1    red   2.380\n",
       "2  white   5.560"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分组，数据的结构不变\n",
    "col.groupby(['color'], as_index=False)['price1'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fuzzy-valve",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "quantitative-improvement",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "sunset-regard",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "boolean-drove",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bulgarian-management",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "marine-transparency",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "atlantic-prefix",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "attempted-reading",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "medieval-performance",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "artificial-gallery",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "spatial-bunny",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "present-relaxation",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "continental-enemy",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "corresponding-sampling",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "encouraging-prairie",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "neural-hungarian",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "extraordinary-current",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "pregnant-scope",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "skilled-corner",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fitted-reservation",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "visible-grain",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "conservative-analyst",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "affecting-print",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "negative-script",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "flush-decade",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "geological-commonwealth",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
